提交 4501d5a5 编写于 作者: G gero3

revert last commit

上级 fe849315
......@@ -84,7 +84,7 @@ Sidebar.Object3D = function ( editor ) {
var objectNameRow = new UI.Panel();
var objectName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
editor.nameObject( editor.selected, objectName.getValue() );
editor.nameObject( editor.selected, objectName.getValue() );
} );
......
......@@ -203,17 +203,17 @@ THREE.BlendCharacter = function () {
this.unPauseAll = function() {
for ( var a in this.animations ) {
for ( var a in this.animations ) {
if ( this.animations[ a ].isPlaying && this.animations[ a ].isPaused ) {
if ( this.animations[ a ].isPlaying && this.animations[ a ].isPaused ) {
this.animations[ a ].pause();
this.animations[ a ].pause();
}
}
}
}
};
};
this.stopAll = function() {
......
......@@ -18,12 +18,12 @@ THREE.Curves = {};
THREE.Curves.GrannyKnot = THREE.Curve.create( function() {},
function(t) {
t = 2 * Math.PI * t;
t = 2 * Math.PI * t;
var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
return new THREE.Vector3(x, y, z).multiplyScalar(20);
var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
return new THREE.Vector3(x, y, z).multiplyScalar(20);
}
);
......@@ -214,10 +214,10 @@ THREE.Curves.TrefoilPolynomialKnot = THREE.Curve.create(
// }
var scaleTo = function(x, y, t) {
var r = y - x;
return t * r + x;
var r = y - x;
return t * r + x;
}
}
THREE.Curves.FigureEightPolynomialKnot = THREE.Curve.create(
......
......@@ -108,9 +108,9 @@ THREE.ParametricGeometries.TubeGeometry = function(path, segments, radius, segme
binormals = frames.binormals;
// proxy internals
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
......
此差异已折叠。
......@@ -19,18 +19,18 @@ var SPARKS = {};
SPARKS.Emitter = function (counter) {
this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
this._particles = [];
this._particles = [];
this._initializers = []; // use for creation of particles
this._actions = []; // uses action to update particles
this._activities = []; // not supported yet
this._initializers = []; // use for creation of particles
this._actions = []; // uses action to update particles
this._activities = []; // not supported yet
this._handlers = [];
this._handlers = [];
this.callbacks = {};
this.callbacks = {};
};
......@@ -99,108 +99,108 @@ SPARKS.Emitter.prototype = {
// Update particle engine in seconds, not milliseconds
update: function(time) {
var i, j;
var len = this._counter.updateEmitter( this, time );
var i, j;
var len = this._counter.updateEmitter( this, time );
// Create particles
for ( i = 0; i < len; i ++ ) {
this.createParticle();
}
for ( i = 0; i < len; i ++ ) {
this.createParticle();
}
// Update activities
len = this._activities.length;
for ( i = 0; i < len; i ++ )
len = this._activities.length;
for ( i = 0; i < len; i ++ )
{
this._activities[i].update( this, time );
}
this._activities[i].update( this, time );
}
len = this._actions.length;
len = this._actions.length;
var particle;
var action;
var len2 = this._particles.length;
var particle;
var action;
var len2 = this._particles.length;
for ( j = 0; j < len; j ++ )
for ( j = 0; j < len; j ++ )
{
action = this._actions[j];
for ( i = 0; i < len2; ++ i )
action = this._actions[j];
for ( i = 0; i < len2; ++ i )
{
particle = this._particles[i];
action.update( this, particle, time );
}
}
particle = this._particles[i];
action.update( this, particle, time );
}
}
// remove dead particles
for ( i = len2; i --; )
for ( i = len2; i --; )
{
particle = this._particles[i];
if ( particle.isDead )
particle = this._particles[i];
if ( particle.isDead )
{
//particle =
this._particles.splice( i, 1 );
this.dispatchEvent("dead", particle);
SPARKS.VectorPool.release(particle.position); //
SPARKS.VectorPool.release(particle.velocity);
this._particles.splice( i, 1 );
this.dispatchEvent("dead", particle);
SPARKS.VectorPool.release(particle.position); //
SPARKS.VectorPool.release(particle.velocity);
} else {
this.dispatchEvent("updated", particle);
}
}
} else {
this.dispatchEvent("updated", particle);
}
}
this.dispatchEvent("loopUpdated");
this.dispatchEvent("loopUpdated");
},
createParticle: function() {
var particle = new SPARKS.Particle();
var particle = new SPARKS.Particle();
// In future, use a Particle Factory
var len = this._initializers.length, i;
var len = this._initializers.length, i;
for ( i = 0; i < len; i ++ ) {
this._initializers[i].initialize( this, particle );
}
for ( i = 0; i < len; i ++ ) {
this._initializers[i].initialize( this, particle );
}
this._particles.push( particle );
this._particles.push( particle );
this.dispatchEvent("created", particle); // ParticleCreated
this.dispatchEvent("created", particle); // ParticleCreated
return particle;
return particle;
},
addInitializer: function (initializer) {
this._initializers.push(initializer);
this._initializers.push(initializer);
},
addAction: function (action) {
this._actions.push(action);
this._actions.push(action);
},
removeInitializer: function (initializer) {
var index = this._initializers.indexOf(initializer);
if (index > -1) {
this._initializers.splice( index, 1 );
}
var index = this._initializers.indexOf(initializer);
if (index > -1) {
this._initializers.splice( index, 1 );
}
},
removeAction: function (action) {
var index = this._actions.indexOf(action);
if (index > -1) {
this._actions.splice( index, 1 );
}
var index = this._actions.indexOf(action);
if (index > -1) {
this._actions.splice( index, 1 );
}
//console.log('removeAction', index, this._actions);
},
addCallback: function(name, callback) {
this.callbacks[name] = callback;
this.callbacks[name] = callback;
},
dispatchEvent: function(name, args) {
var callback = this.callbacks[name];
if (callback) {
callback(args);
}
var callback = this.callbacks[name];
if (callback) {
callback(args);
}
}
......@@ -227,7 +227,7 @@ SPARKS.EVENT_LOOP_UPDATED = "loopUpdated";
// Number of particles per seconds
SPARKS.SteadyCounter = function(rate) {
this.rate = rate;
this.rate = rate;
// we use a shortfall counter to make up for slow emitters
this.leftover = 0;
......@@ -277,31 +277,31 @@ SPARKS.Particle = function() {
/**
* The lifetime of the particle, in seconds.
*/
this.lifetime = 0;
this.lifetime = 0;
/**
* The age of the particle, in seconds.
*/
this.age = 0;
this.age = 0;
/**
* The energy of the particle.
*/
this.energy = 1;
this.energy = 1;
/**
* Whether the particle is dead and should be removed from the stage.
*/
this.isDead = false;
this.isDead = false;
this.target = null; // tag
this.target = null; // tag
/**
* For 3D
*/
this.position = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
this.velocity = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
this.position = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
this.velocity = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
this._oldvelocity = SPARKS.VectorPool.get().set(0, 0, 0);
// rotation vec3
// angVelocity vec3
......@@ -317,26 +317,26 @@ SPARKS.Particle = function() {
* update function
*********************************/
SPARKS.Action = function() {
this._priority = 0;
this._priority = 0;
};
SPARKS.Age = function(easing) {
this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
};
SPARKS.Age.prototype.update = function (emitter, particle, time) {
particle.age += time;
if ( particle.age >= particle.lifetime )
particle.age += time;
if ( particle.age >= particle.lifetime )
{
particle.energy = 0;
particle.isDead = true;
}
particle.energy = 0;
particle.isDead = true;
}
else
{
var t = this._easing(particle.age / particle.lifetime);
particle.energy = -1 * t + 1;
}
{
var t = this._easing(particle.age / particle.lifetime);
particle.energy = -1 * t + 1;
}
};
/*
......@@ -360,9 +360,9 @@ SPARKS.Move = function() {
SPARKS.Move.prototype.update = function(emitter, particle, time) {
// attempt verlet velocity updating.
var p = particle.position;
var p = particle.position;
var v = particle.velocity;
var old = particle._oldvelocity;
var old = particle._oldvelocity;
if (this._velocityVerlet) {
p.x += (v.x + old.x) * 0.5 * time;
......@@ -384,12 +384,12 @@ SPARKS.Move.prototype.update = function(emitter, particle, time) {
/* Marks particles found in specified zone dead */
SPARKS.DeathZone = function(zone) {
this.zone = zone;
this.zone = zone;
};
SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
if (this.zone.contains(particle.position)) {
if (this.zone.contains(particle.position)) {
particle.isDead = true;
}
......@@ -400,12 +400,12 @@ SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
*/
SPARKS.ActionZone = function(action, zone) {
this.action = action;
this.zone = zone;
this.zone = zone;
};
SPARKS.ActionZone.prototype.update = function(emitter, particle, time) {
if (this.zone.contains(particle.position)) {
if (this.zone.contains(particle.position)) {
this.action.update( emitter, particle, time );
}
......@@ -421,20 +421,20 @@ SPARKS.Accelerate = function(x,y,z) {
return;
}
this.acceleration = new THREE.Vector3(x,y,z);
this.acceleration = new THREE.Vector3(x,y,z);
};
SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
var acc = this.acceleration;
var acc = this.acceleration;
var v = particle.velocity;
var v = particle.velocity;
particle._oldvelocity.set(v.x, v.y, v.z);
v.x += acc.x * time;
v.y += acc.y * time;
v.z += acc.z * time;
v.x += acc.x * time;
v.y += acc.y * time;
v.z += acc.z * time;
};
......@@ -442,16 +442,16 @@ SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
* Accelerate Factor accelerate based on a factor of particle's velocity.
*/
SPARKS.AccelerateFactor = function(factor) {
this.factor = factor;
this.factor = factor;
};
SPARKS.AccelerateFactor.prototype.update = function(emitter, particle, time) {
var factor = this.factor;
var factor = this.factor;
var v = particle.velocity;
var v = particle.velocity;
var len = v.length();
var adjFactor;
if (len > 0) {
if (len > 0) {
adjFactor = factor * time / len;
adjFactor += 1;
......@@ -475,14 +475,14 @@ SPARKS.AccelerateVelocity = function(factor) {
};
SPARKS.AccelerateVelocity.prototype.update = function(emitter, particle, time) {
var factor = this.factor;
var factor = this.factor;
var v = particle.velocity;
var v = particle.velocity;
v.z += - v.x * factor;
v.y += v.z * factor;
v.x += v.y * factor;
v.z += - v.x * factor;
v.y += v.z * factor;
v.x += v.y * factor;
};
......@@ -494,18 +494,18 @@ SPARKS.RandomDrift = function(x,y,z) {
return;
}
this.drift = new THREE.Vector3(x,y,z);
this.drift = new THREE.Vector3(x,y,z);
}
SPARKS.RandomDrift.prototype.update = function(emitter, particle, time) {
var drift = this.drift;
var drift = this.drift;
var v = particle.velocity;
var v = particle.velocity;
v.x += ( Math.random() - 0.5 ) * drift.x * time;
v.y += ( Math.random() - 0.5 ) * drift.y * time;
v.z += ( Math.random() - 0.5 ) * drift.z * time;
v.x += ( Math.random() - 0.5 ) * drift.x * time;
v.y += ( Math.random() - 0.5 ) * drift.y * time;
v.z += ( Math.random() - 0.5 ) * drift.z * time;
};
......@@ -521,29 +521,29 @@ SPARKS.Zone = function() {
// TODO, contains() for Zone
SPARKS.PointZone = function(pos) {
this.pos = pos;
this.pos = pos;
};
SPARKS.PointZone.prototype.getLocation = function() {
return this.pos;
return this.pos;
};
SPARKS.PointZone = function(pos) {
this.pos = pos;
this.pos = pos;
};
SPARKS.PointZone.prototype.getLocation = function() {
return this.pos;
return this.pos;
};
SPARKS.LineZone = function(start, end) {
this.start = start;
this.start = start;
this.end = end;
this._length = end.clone().sub( start );
};
SPARKS.LineZone.prototype.getLocation = function() {
var len = this._length.clone();
var len = this._length.clone();
len.multiplyScalar( Math.random() );
return len.add( this.start );
......@@ -552,7 +552,7 @@ SPARKS.LineZone.prototype.getLocation = function() {
// Basically a RectangleZone
SPARKS.ParallelogramZone = function(corner, side1, side2) {
this.corner = corner;
this.corner = corner;
this.side1 = side1;
this.side2 = side2;
};
......@@ -567,7 +567,7 @@ SPARKS.ParallelogramZone.prototype.getLocation = function() {
};
SPARKS.CubeZone = function(position, x, y, z) {
this.position = position;
this.position = position;
this.x = x;
this.y = y;
this.z = z;
......@@ -674,29 +674,29 @@ SPARKS.DiscZone.prototype.getLocation = function() {
*/
SPARKS.SphereCapZone = function(x, y, z, minr, maxr, angle) {
this.x = x;
this.y = y;
this.z = z;
this.minr = minr;
this.maxr = maxr;
this.angle = angle;
this.x = x;
this.y = y;
this.z = z;
this.minr = minr;
this.maxr = maxr;
this.angle = angle;
};
SPARKS.SphereCapZone.prototype.getLocation = function() {
var theta = Math.PI * 2 * SPARKS.Utils.random();
var r = SPARKS.Utils.random();
var theta = Math.PI * 2 * SPARKS.Utils.random();
var r = SPARKS.Utils.random();
//new THREE.Vector3
var v = SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
var v = SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
//v.length = StardustMath.interpolate(0, _minRadius, 1, _maxRadius, Math.random());
var i = this.minr - ((this.minr - this.maxr) * Math.random() );
v.multiplyScalar(i);
var i = this.minr - ((this.minr - this.maxr) * Math.random() );
v.multiplyScalar(i);
v.__markedForReleased = true;
return v;
return v;
};
......@@ -709,33 +709,33 @@ SPARKS.SphereCapZone.prototype.getLocation = function() {
// Specifies random life between max and min
SPARKS.Lifetime = function(min, max) {
this._min = min;
this._min = min;
this._max = max ? max : min;
this._max = max ? max : min;
};
SPARKS.Lifetime.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
};
SPARKS.Position = function(zone) {
this.zone = zone;
this.zone = zone;
};
SPARKS.Position.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
var pos = this.zone.getLocation();
particle.position.set(pos.x, pos.y, pos.z);
var pos = this.zone.getLocation();
particle.position.set(pos.x, pos.y, pos.z);
};
SPARKS.Velocity = function(zone) {
this.zone = zone;
this.zone = zone;
};
SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
var pos = this.zone.getLocation();
particle.velocity.set(pos.x, pos.y, pos.z);
var pos = this.zone.getLocation();
particle.velocity.set(pos.x, pos.y, pos.z);
if (pos.__markedForReleased) {
//console.log("release");
SPARKS.VectorPool.release(pos);
......@@ -744,17 +744,17 @@ SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*P
};
SPARKS.Target = function(target, callback) {
this.target = target;
this.callback = callback;
this.target = target;
this.callback = callback;
};
SPARKS.Target.prototype.initialize = function( emitter, particle ) {
if (this.callback) {
particle.target = this.callback();
} else {
particle.target = this.target;
}
if (this.callback) {
particle.target = this.callback();
} else {
particle.target = this.target;
}
};
......@@ -807,7 +807,7 @@ SPARKS.VectorPool = {
*********************************/
SPARKS.Utils = {
random: function() {
return Math.random();
return Math.random();
},
DEGREE_TO_RADIAN: Math.PI / 180,
TWOPI: Math.PI * 2,
......
......@@ -6,50 +6,50 @@
THREE.MouseControls = function ( object ) {
var scope = this;
var PI_2 = Math.PI / 2;
var mouseQuat = {
var scope = this;
var PI_2 = Math.PI / 2;
var mouseQuat = {
x: new THREE.Quaternion(),
y: new THREE.Quaternion()
};
var object = object;
var xVector = new THREE.Vector3( 1, 0, 0 );
var yVector = new THREE.Vector3( 0, 1, 0 );
var object = object;
var xVector = new THREE.Vector3( 1, 0, 0 );
var yVector = new THREE.Vector3( 0, 1, 0 );
var onMouseMove = function ( event ) {
var onMouseMove = function ( event ) {
if ( scope.enabled === false ) return;
if ( scope.enabled === false ) return;
var orientation = scope.orientation;
var orientation = scope.orientation;
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
orientation.y += movementX * 0.0025;
orientation.x += movementY * 0.0025;
orientation.y += movementX * 0.0025;
orientation.x += movementY * 0.0025;
orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
orientation.x = Math.max( - PI_2, Math.min( PI_2, orientation.x ) );
};
};
this.enabled = true;
this.enabled = true;
this.orientation = {
this.orientation = {
x: 0,
y: 0,
};
this.update = function() {
this.update = function() {
if ( this.enabled === false ) return;
if ( this.enabled === false ) return;
mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
return;
mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x)
return;
};
};
document.addEventListener( 'mousemove', onMouseMove, false );
document.addEventListener( 'mousemove', onMouseMove, false );
};
......@@ -30,8 +30,8 @@
} else {
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
}
......@@ -65,8 +65,8 @@
} else {
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
this.color.copy( this.oldColor );
this.opacity = this.oldOpacity;
}
......@@ -331,15 +331,15 @@
var CircleGeometry = function ( radius, facing, arc ) {
var geometry = new THREE.Geometry();
arc = arc ? arc : 1;
for ( var i = 0; i <= 64 * arc; ++ i ) {
if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) );
}
var geometry = new THREE.Geometry();
arc = arc ? arc : 1;
for ( var i = 0; i <= 64 * arc; ++ i ) {
if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) );
if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) );
}
return geometry;
return geometry;
};
this.handleGizmos = {
......
......@@ -56,7 +56,7 @@ THREE.VREffect = function ( renderer, done ) {
}
if ( done ) {
if ( !vrHMD ) {
error = 'HMD not available';
error = 'HMD not available';
}
done( error );
}
......
......@@ -176,14 +176,14 @@ THREE.ConvexGeometry = function( vertices ) {
for ( var j = 0; j < 3; j ++ ) {
if ( newId[ face[ j ] ] === undefined ) {
if ( newId[ face[ j ] ] === undefined ) {
newId[ face[ j ] ] = id ++;
this.vertices.push( vertices[ face[ j ] ] );
newId[ face[ j ] ] = id ++;
this.vertices.push( vertices[ face[ j ] ] );
}
}
face[ j ] = newId[ face[ j ] ];
face[ j ] = newId[ face[ j ] ];
}
......
......@@ -191,8 +191,8 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
vertices = this.clipFace( vertices, new THREE.Vector3( -1, 0, 0 ) );
}
if ( check.y ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
}
if ( check.z ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, 1 ) );
......
此差异已折叠。
......@@ -735,7 +735,7 @@ THREE.ColladaLoader = function () {
// move vertices to bind shape
for ( i = 0; i < geometry.vertices.length; i ++ ) {
geometry.vertices[i].applyMatrix4( skinController.skin.bindShapeMatrix );
geometry.vertices[i].applyMatrix4( skinController.skin.bindShapeMatrix );
}
var skinIndices = [];
......@@ -1343,17 +1343,17 @@ THREE.ColladaLoader = function () {
function getLibraryNode( id ) {
var nodes = COLLADA.querySelectorAll('library_nodes node');
var nodes = COLLADA.querySelectorAll('library_nodes node');
for ( var i = 0; i < nodes.length; i ++ ) {
for ( var i = 0; i < nodes.length; i ++ ) {
var attObj = nodes[i].attributes.getNamedItem('id');
if ( attObj && attObj.value === id ) {
return nodes[i];
}
}
var attObj = nodes[i].attributes.getNamedItem('id');
if ( attObj && attObj.value === id ) {
return nodes[i];
}
}
return undefined;
return undefined;
};
......@@ -3365,35 +3365,35 @@ THREE.ColladaLoader = function () {
//for (var i = 0; i < this.accessor.params.length; i++) {
var param = this.accessor.params[ 0 ];
var param = this.accessor.params[ 0 ];
//console.log(param.name + " " + param.type);
switch ( param.type ) {
switch ( param.type ) {
case 'IDREF':
case 'Name': case 'name':
case 'float':
case 'IDREF':
case 'Name': case 'name':
case 'float':
return this.data;
return this.data;
case 'float4x4':
case 'float4x4':
for ( var j = 0; j < this.data.length; j += 16 ) {
for ( var j = 0; j < this.data.length; j += 16 ) {
var s = this.data.slice( j, j + 16 );
var m = getConvertedMat4( s );
result.push( m );
}
var s = this.data.slice( j, j + 16 );
var m = getConvertedMat4( s );
result.push( m );
}
break;
break;
default:
default:
console.log( 'ColladaLoader: Source: Read dont know how to read ' + param.type + '.' );
break;
console.log( 'ColladaLoader: Source: Read dont know how to read ' + param.type + '.' );
break;
}
}
//}
......
......@@ -77,16 +77,16 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
}
pvrDatas.dataPtr = 52 + metaLen;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numFaces;
pvrDatas.numMipmaps = numMipmaps;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numFaces;
pvrDatas.numMipmaps = numMipmaps;
pvrDatas.isCubemap = (numFaces === 6);
pvrDatas.isCubemap = (numFaces === 6);
return THREE.PVRLoader._extract( pvrDatas );
return THREE.PVRLoader._extract( pvrDatas );
};
THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
......@@ -133,18 +133,18 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
pvrDatas.dataPtr = headerLength;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numSurfs;
pvrDatas.numMipmaps = numMipmaps + 1;
pvrDatas.bpp = bpp;
pvrDatas.format = format;
pvrDatas.width = width;
pvrDatas.height = height;
pvrDatas.numSurfaces = numSurfs;
pvrDatas.numMipmaps = numMipmaps + 1;
// guess cubemap type seems tricky in v2
// it juste a pvr containing 6 surface (no explicit cubemap type)
pvrDatas.isCubemap = (numSurfs === 6);
pvrDatas.isCubemap = (numSurfs === 6);
return THREE.PVRLoader._extract( pvrDatas );
return THREE.PVRLoader._extract( pvrDatas );
};
......
......@@ -30,11 +30,11 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
rgbe_error = function(rgbe_error_code, msg) {
switch (rgbe_error_code) {
case rgbe_read_error: console.error("THREE.RGBELoader Read Error: " + (msg||''));
break;
break;
case rgbe_write_error: console.error("THREE.RGBELoader Write Error: " + (msg||''));
break;
break;
case rgbe_format_error: console.error("THREE.RGBELoader Bad File Format: " + (msg||''));
break;
break;
default:
case rgbe_memory_error: console.error("THREE.RGBELoader: Error: " + (msg||''));
}
......
......@@ -110,15 +110,15 @@ THREE.STLLoader.prototype = {
(reader.getUint8(index + 4) == 0x52 /*'R'*/) &&
(reader.getUint8(index + 5) == 0x3D /*'='*/)) {
hasColors = true;
colors = new Float32Array( faces * 3 * 3);
hasColors = true;
colors = new Float32Array( faces * 3 * 3);
defaultR = reader.getUint8(index + 6) / 255;
defaultG = reader.getUint8(index + 7) / 255;
defaultB = reader.getUint8(index + 8) / 255;
alpha = reader.getUint8(index + 9) / 255;
}
defaultR = reader.getUint8(index + 6) / 255;
defaultG = reader.getUint8(index + 7) / 255;
defaultB = reader.getUint8(index + 8) / 255;
alpha = reader.getUint8(index + 9) / 255;
}
}
var dataOffset = 84;
var faceLength = 12 * 4 + 2;
......
......@@ -154,8 +154,8 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
pixel_total,
palettes;
pixel_size = header.pixel_size >> 3;
pixel_total = header.width * header.height * pixel_size;
pixel_size = header.pixel_size >> 3;
pixel_total = header.width * header.height * pixel_size;
// Read palettes
if ( use_pal ) {
......@@ -178,12 +178,12 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
if (c & 0x80) {
// Bind pixel tmp array
for (i = 0; i < pixel_size; ++ i) {
pixels[i] = data[offset ++];
pixels[i] = data[offset ++];
}
// Copy pixel array
for (i = 0; i < count; ++ i) {
pixel_data.set(pixels, shift + i * pixel_size);
pixel_data.set(pixels, shift + i * pixel_size);
}
shift += pixel_size * count;
......@@ -192,7 +192,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
// Raw pixels.
count *= pixel_size;
for (i = 0; i < count; ++ i) {
pixel_data[shift + i] = data[offset ++];
pixel_data[shift + i] = data[offset ++];
}
shift += count;
}
......@@ -214,7 +214,7 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
var colormap = palettes;
var color, i = 0, x, y;
var width = header.width;
var width = header.width;
for (y = y_start; y !== y_end; y += y_step) {
for (x = x_start; x !== x_end; x += x_step, i ++) {
......
此差异已折叠。
......@@ -260,7 +260,7 @@ THREE.VRMLLoader.prototype = {
// end of current face
if (parts[ind] === "-1") {
if (index.length > 0) {
this.indexes.push(index);
this.indexes.push(index);
}
// start new one
......
此差异已折叠。
此差异已折叠。
......@@ -430,7 +430,7 @@ THREE.SceneLoader.prototype = {
} else if ( objJSON.target ) {
camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );
camera.lookAt( new THREE.Vector3().fromArray( objJSON.target ) );
}
......
......@@ -49,35 +49,35 @@
*/
var global = window;
(function (root, factory) {
if (typeof exports === 'object') {
if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
factory(module.exports);
} else if (typeof define === 'function' && define.amd) {
factory(module.exports);
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], function () {
return factory(root);
});
} else {
define([], function () {
return factory(root);
});
} else {
// Browser globals
factory(root);
}
factory(root);
}
}(this, function (root) {
"use strict";
"use strict";
var categoriesDepsOrder = [ "buffers", "bufferViews", "images", "videos", "samplers", "textures", "shaders", "programs", "techniques", "materials", "accessors", "meshes", "cameras", "lights", "skins", "nodes", "scenes", "animations" ];
var categoriesDepsOrder = [ "buffers", "bufferViews", "images", "videos", "samplers", "textures", "shaders", "programs", "techniques", "materials", "accessors", "meshes", "cameras", "lights", "skins", "nodes", "scenes", "animations" ];
var glTFParser = Object.create(Object.prototype, {
var glTFParser = Object.create(Object.prototype, {
_rootDescription: { value: null, writable: true },
rootDescription: {
set: function(value) {
this._rootDescription = value;
this._rootDescription = value;
},
get: function() {
return this._rootDescription;
return this._rootDescription;
}
},
......@@ -86,34 +86,34 @@ var global = window;
//detect absolute path following the same protocol than window.location
_isAbsolutePath: {
value: function(path) {
var isAbsolutePathRegExp = new RegExp("^" + window.location.protocol, "i");
var isAbsolutePathRegExp = new RegExp("^" + window.location.protocol, "i");
return path.match(isAbsolutePathRegExp) ? true : false;
return path.match(isAbsolutePathRegExp) ? true : false;
}
},
resolvePathIfNeeded: {
value: function(path) {
if (this._isAbsolutePath(path)) {
return path;
}
if (this._isAbsolutePath(path)) {
return path;
}
return this.baseURL + path;
return this.baseURL + path;
}
},
_resolvePathsForCategories: {
value: function(categories) {
categories.forEach( function(category) {
var descriptions = this.json[category];
if (descriptions) {
var descriptionKeys = Object.keys(descriptions);
descriptionKeys.forEach( function(descriptionKey) {
var description = descriptions[descriptionKey];
description.path = this.resolvePathIfNeeded(description.path);
}, this);
}
}, this);
categories.forEach( function(category) {
var descriptions = this.json[category];
if (descriptions) {
var descriptionKeys = Object.keys(descriptions);
descriptionKeys.forEach( function(descriptionKey) {
var description = descriptions[descriptionKey];
description.path = this.resolvePathIfNeeded(description.path);
}, this);
}
}, this);
}
},
......@@ -125,13 +125,13 @@ var global = window;
json: {
enumerable: true,
get: function() {
return this._json;
return this._json;
},
set: function(value) {
if (this._json !== value) {
this._json = value;
this._resolvePathsForCategories([ "buffers", "shaders", "images", "videos" ]);
}
if (this._json !== value) {
this._json = value;
this._resolvePathsForCategories([ "buffers", "shaders", "images", "videos" ]);
}
}
},
......@@ -142,60 +142,60 @@ var global = window;
getEntryDescription: {
value: function (entryID, entryType) {
var entries = null;
var entries = null;
var category = entryType;
entries = this.rootDescription[category];
if (!entries) {
console.log("ERROR:CANNOT find expected category named:" + category);
return null;
}
var category = entryType;
entries = this.rootDescription[category];
if (!entries) {
console.log("ERROR:CANNOT find expected category named:" + category);
return null;
}
return entries ? entries[entryID] : null;
return entries ? entries[entryID] : null;
}
},
_stepToNextCategory: {
value: function() {
this._state.categoryIndex = this.getNextCategoryIndex(this._state.categoryIndex + 1);
if (this._state.categoryIndex !== -1) {
this._state.categoryState.index = 0;
return true;
}
this._state.categoryIndex = this.getNextCategoryIndex(this._state.categoryIndex + 1);
if (this._state.categoryIndex !== -1) {
this._state.categoryState.index = 0;
return true;
}
return false;
return false;
}
},
_stepToNextDescription: {
enumerable: false,
value: function() {
var categoryState = this._state.categoryState;
var keys = categoryState.keys;
if (!keys) {
console.log("INCONSISTENCY ERROR");
return false;
}
categoryState.index ++;
categoryState.keys = null;
if (categoryState.index >= keys.length) {
return this._stepToNextCategory();
}
return false;
var categoryState = this._state.categoryState;
var keys = categoryState.keys;
if (!keys) {
console.log("INCONSISTENCY ERROR");
return false;
}
categoryState.index ++;
categoryState.keys = null;
if (categoryState.index >= keys.length) {
return this._stepToNextCategory();
}
return false;
}
},
hasCategory: {
value: function(category) {
return this.rootDescription[category] ? true : false;
return this.rootDescription[category] ? true : false;
}
},
_handleState: {
value: function() {
var methodForType = {
var methodForType = {
"buffers" : this.handleBuffer,
"bufferViews" : this.handleBufferView,
"shaders" : this.handleShader,
......@@ -217,46 +217,46 @@ var global = window;
};
var success = true;
while (this._state.categoryIndex !== -1) {
var category = categoriesDepsOrder[this._state.categoryIndex];
var categoryState = this._state.categoryState;
var keys = categoryState.keys;
if (!keys) {
categoryState.keys = keys = Object.keys(this.rootDescription[category]);
if (keys) {
if (keys.length == 0) {
this._stepToNextDescription();
continue;
}
}
}
var type = category;
var entryID = keys[categoryState.index];
var description = this.getEntryDescription(entryID, type);
if (!description) {
if (this.handleError) {
this.handleError("INCONSISTENCY ERROR: no description found for entry " + entryID);
success = false;
break;
}
} else {
if (methodForType[type]) {
if (methodForType[type].call(this, entryID, description, this._state.userInfo) === false) {
success = false;
break;
}
}
this._stepToNextDescription();
}
}
if (this.handleLoadCompleted) {
this.handleLoadCompleted(success);
}
var success = true;
while (this._state.categoryIndex !== -1) {
var category = categoriesDepsOrder[this._state.categoryIndex];
var categoryState = this._state.categoryState;
var keys = categoryState.keys;
if (!keys) {
categoryState.keys = keys = Object.keys(this.rootDescription[category]);
if (keys) {
if (keys.length == 0) {
this._stepToNextDescription();
continue;
}
}
}
var type = category;
var entryID = keys[categoryState.index];
var description = this.getEntryDescription(entryID, type);
if (!description) {
if (this.handleError) {
this.handleError("INCONSISTENCY ERROR: no description found for entry " + entryID);
success = false;
break;
}
} else {
if (methodForType[type]) {
if (methodForType[type].call(this, entryID, description, this._state.userInfo) === false) {
success = false;
break;
}
}
this._stepToNextDescription();
}
}
if (this.handleLoadCompleted) {
this.handleLoadCompleted(success);
}
}
},
......@@ -264,40 +264,40 @@ var global = window;
_loadJSONIfNeeded: {
enumerable: true,
value: function(callback) {
var self = this;
var self = this;
//FIXME: handle error
if (!this._json) {
var jsonPath = this._path;
var i = jsonPath.lastIndexOf("/");
this.baseURL = (i !== 0) ? jsonPath.substring(0, i + 1) : '';
var jsonfile = new XMLHttpRequest();
jsonfile.open("GET", jsonPath, true);
jsonfile.addEventListener( 'load', function ( event ) {
self.json = JSON.parse(jsonfile.responseText);
if (callback) {
callback(self.json);
}
}, false );
jsonfile.send(null);
} else {
if (callback) {
callback(this.json);
}
}
if (!this._json) {
var jsonPath = this._path;
var i = jsonPath.lastIndexOf("/");
this.baseURL = (i !== 0) ? jsonPath.substring(0, i + 1) : '';
var jsonfile = new XMLHttpRequest();
jsonfile.open("GET", jsonPath, true);
jsonfile.addEventListener( 'load', function ( event ) {
self.json = JSON.parse(jsonfile.responseText);
if (callback) {
callback(self.json);
}
}, false );
jsonfile.send(null);
} else {
if (callback) {
callback(this.json);
}
}
}
},
/* load JSON and assign it as description to the reader */
_buildLoader: {
value: function(callback) {
var self = this;
function JSONReady(json) {
self.rootDescription = json;
if (callback)
var self = this;
function JSONReady(json) {
self.rootDescription = json;
if (callback)
callback(this);
}
}
this._loadJSONIfNeeded(JSONReady);
this._loadJSONIfNeeded(JSONReady);
}
},
......@@ -305,51 +305,51 @@ var global = window;
_getEntryType: {
value: function(entryID) {
var rootKeys = categoriesDepsOrder;
for (var i = 0 ; i < rootKeys.length ; i ++) {
var rootValues = this.rootDescription[rootKeys[i]];
if (rootValues) {
return rootKeys[i];
}
}
return null;
var rootKeys = categoriesDepsOrder;
for (var i = 0 ; i < rootKeys.length ; i ++) {
var rootValues = this.rootDescription[rootKeys[i]];
if (rootValues) {
return rootKeys[i];
}
}
return null;
}
},
getNextCategoryIndex: {
value: function(currentIndex) {
for (var i = currentIndex ; i < categoriesDepsOrder.length ; i ++) {
if (this.hasCategory(categoriesDepsOrder[i])) {
return i;
}
}
for (var i = currentIndex ; i < categoriesDepsOrder.length ; i ++) {
if (this.hasCategory(categoriesDepsOrder[i])) {
return i;
}
}
return -1;
return -1;
}
},
load: {
enumerable: true,
value: function(userInfo, options) {
var self = this;
this._buildLoader(function loaderReady(reader) {
var startCategory = self.getNextCategoryIndex.call(self, 0);
if (startCategory !== -1) {
self._state = { "userInfo" : userInfo,
var self = this;
this._buildLoader(function loaderReady(reader) {
var startCategory = self.getNextCategoryIndex.call(self, 0);
if (startCategory !== -1) {
self._state = { "userInfo" : userInfo,
"options" : options,
"categoryIndex" : startCategory,
"categoryState" : { "index" : "0" } };
self._handleState();
}
});
self._handleState();
}
});
}
},
initWithPath: {
value: function(path) {
this._path = path;
this._json = null;
return this;
this._path = path;
this._json = null;
return this;
}
},
......@@ -359,30 +359,30 @@ var global = window;
//to be invoked by subclass, so that ids can be ensured to not overlap
loaderContext: {
value: function() {
if (typeof this._knownURLs[this._path] === "undefined") {
this._knownURLs[this._path] = Object.keys(this._knownURLs).length;
}
return "__" + this._knownURLs[this._path];
if (typeof this._knownURLs[this._path] === "undefined") {
this._knownURLs[this._path] = Object.keys(this._knownURLs).length;
}
return "__" + this._knownURLs[this._path];
}
},
initWithJSON: {
value: function(json, baseURL) {
this.json = json;
this.baseURL = baseURL;
if (!baseURL) {
console.log("WARNING: no base URL passed to Reader:initWithJSON");
}
return this;
this.json = json;
this.baseURL = baseURL;
if (!baseURL) {
console.log("WARNING: no base URL passed to Reader:initWithJSON");
}
return this;
}
}
});
if (root) {
root.glTFParser = glTFParser;
}
if (root) {
root.glTFParser = glTFParser;
}
return glTFParser;
return glTFParser;
}));
......@@ -26,8 +26,8 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
value: function() {
this._streams = {};
this._streamsStatus = {};
this._resources = {};
this._resourcesStatus = {};
this._resources = {};
this._resourcesStatus = {};
}
},
......@@ -35,60 +35,60 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
_containsResource: {
enumerable: false,
value: function(resourceID) {
return this._resources[resourceID] ? true : false;
return this._resources[resourceID] ? true : false;
}
},
_storeResource: {
enumerable: false,
value: function(resourceID, resource) {
if (!resourceID) {
console.log("ERROR: entry does not contain id, cannot store");
return;
}
if (!resourceID) {
console.log("ERROR: entry does not contain id, cannot store");
return;
}
if (this._containsResource[resourceID]) {
console.log("WARNING: resource:" + resourceID + " is already stored, overriding");
}
if (this._containsResource[resourceID]) {
console.log("WARNING: resource:" + resourceID + " is already stored, overriding");
}
this._resources[resourceID] = resource;
this._resources[resourceID] = resource;
}
},
_getResource: {
enumerable: false,
value: function(resourceID) {
return this._resources[resourceID];
return this._resources[resourceID];
}
},
_loadStream: {
value: function(path, type, delegate) {
var self = this;
var self = this;
if (!type) {
delegate.handleError(THREE.GLTFLoaderUtils.INVALID_TYPE, null);
return;
}
if (!type) {
delegate.handleError(THREE.GLTFLoaderUtils.INVALID_TYPE, null);
return;
}
if (!path) {
delegate.handleError(THREE.GLTFLoaderUtils.INVALID_PATH);
return;
}
if (!path) {
delegate.handleError(THREE.GLTFLoaderUtils.INVALID_PATH);
return;
}
var xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.responseType = (type === this.ARRAY_BUFFER) ? "arraybuffer" : "text";
var xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.responseType = (type === this.ARRAY_BUFFER) ? "arraybuffer" : "text";
//if this is not specified, 1 "big blob" scenes fails to load.
xhr.setRequestHeader("If-Modified-Since", "Sat, 01 Jan 1970 00:00:00 GMT");
xhr.addEventListener( 'load', function ( event ) {
delegate.streamAvailable(path, xhr.response);
}, false );
xhr.addEventListener( 'error', function ( event ) {
delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, xhr.status);
}, false );
xhr.send(null);
xhr.setRequestHeader("If-Modified-Since", "Sat, 01 Jan 1970 00:00:00 GMT");
xhr.addEventListener( 'load', function ( event ) {
delegate.streamAvailable(path, xhr.response);
}, false );
xhr.addEventListener( 'error', function ( event ) {
delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, xhr.status);
}, false );
xhr.send(null);
}
},
......@@ -97,86 +97,86 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
_handleRequest: {
value: function(request) {
var resourceStatus = this._resourcesStatus[request.id];
if (resourceStatus)
var resourceStatus = this._resourcesStatus[request.id];
if (resourceStatus)
{
this._resourcesStatus[request.id] ++;
}
this._resourcesStatus[request.id] ++;
}
else
{
this._resourcesStatus[request.id] = 1;
}
{
this._resourcesStatus[request.id] = 1;
}
var streamStatus = this._streamsStatus[request.path];
if (streamStatus && streamStatus.status === "loading" )
var streamStatus = this._streamsStatus[request.path];
if (streamStatus && streamStatus.status === "loading" )
{
streamStatus.requests.push(request);
return;
}
streamStatus.requests.push(request);
return;
}
this._streamsStatus[request.path] = { status : "loading", requests : [ request ] };
this._streamsStatus[request.path] = { status : "loading", requests : [ request ] };
var self = this;
var processResourceDelegate = {};
processResourceDelegate.streamAvailable = function(path, res_) {
var streamStatus = self._streamsStatus[path];
var requests = streamStatus.requests;
requests.forEach( function(req_) {
var subArray = res_.slice(req_.range[0], req_.range[1]);
var convertedResource = req_.delegate.convert(subArray, req_.ctx);
self._storeResource(req_.id, convertedResource);
req_.delegate.resourceAvailable(convertedResource, req_.ctx);
-- self._resourcesStatus[req_.id];
}, this);
var self = this;
var processResourceDelegate = {};
processResourceDelegate.streamAvailable = function(path, res_) {
var streamStatus = self._streamsStatus[path];
var requests = streamStatus.requests;
requests.forEach( function(req_) {
var subArray = res_.slice(req_.range[0], req_.range[1]);
var convertedResource = req_.delegate.convert(subArray, req_.ctx);
self._storeResource(req_.id, convertedResource);
req_.delegate.resourceAvailable(convertedResource, req_.ctx);
-- self._resourcesStatus[req_.id];
}, this);
delete self._streamsStatus[path];
delete self._streamsStatus[path];
};
};
processResourceDelegate.handleError = function(errorCode, info) {
request.delegate.handleError(errorCode, info);
}
processResourceDelegate.handleError = function(errorCode, info) {
request.delegate.handleError(errorCode, info);
}
this._loadStream(request.path, request.type, processResourceDelegate);
this._loadStream(request.path, request.type, processResourceDelegate);
}
},
_elementSizeForGLType: {
value: function(glType) {
switch (glType) {
case WebGLRenderingContext.FLOAT :
return Float32Array.BYTES_PER_ELEMENT;
case WebGLRenderingContext.UNSIGNED_BYTE :
return Uint8Array.BYTES_PER_ELEMENT;
case WebGLRenderingContext.UNSIGNED_SHORT :
return Uint16Array.BYTES_PER_ELEMENT;
case WebGLRenderingContext.FLOAT_VEC2 :
return Float32Array.BYTES_PER_ELEMENT * 2;
case WebGLRenderingContext.FLOAT_VEC3 :
return Float32Array.BYTES_PER_ELEMENT * 3;
case WebGLRenderingContext.FLOAT_VEC4 :
return Float32Array.BYTES_PER_ELEMENT * 4;
case WebGLRenderingContext.FLOAT_MAT3 :
return Float32Array.BYTES_PER_ELEMENT * 9;
case WebGLRenderingContext.FLOAT_MAT4 :
return Float32Array.BYTES_PER_ELEMENT * 16;
default:
return null;
}
switch (glType) {
case WebGLRenderingContext.FLOAT :
return Float32Array.BYTES_PER_ELEMENT;
case WebGLRenderingContext.UNSIGNED_BYTE :
return Uint8Array.BYTES_PER_ELEMENT;
case WebGLRenderingContext.UNSIGNED_SHORT :
return Uint16Array.BYTES_PER_ELEMENT;
case WebGLRenderingContext.FLOAT_VEC2 :
return Float32Array.BYTES_PER_ELEMENT * 2;
case WebGLRenderingContext.FLOAT_VEC3 :
return Float32Array.BYTES_PER_ELEMENT * 3;
case WebGLRenderingContext.FLOAT_VEC4 :
return Float32Array.BYTES_PER_ELEMENT * 4;
case WebGLRenderingContext.FLOAT_MAT3 :
return Float32Array.BYTES_PER_ELEMENT * 9;
case WebGLRenderingContext.FLOAT_MAT4 :
return Float32Array.BYTES_PER_ELEMENT * 16;
default:
return null;
}
}
},
_handleWrappedBufferViewResourceLoading: {
value: function(wrappedBufferView, delegate, ctx) {
var bufferView = wrappedBufferView.bufferView;
var buffer = bufferView.buffer;
var byteOffset = wrappedBufferView.byteOffset + bufferView.description.byteOffset;
var range = [ byteOffset, (this._elementSizeForGLType(wrappedBufferView.type) * wrappedBufferView.count) + byteOffset ];
var bufferView = wrappedBufferView.bufferView;
var buffer = bufferView.buffer;
var byteOffset = wrappedBufferView.byteOffset + bufferView.description.byteOffset;
var range = [ byteOffset, (this._elementSizeForGLType(wrappedBufferView.type) * wrappedBufferView.count) + byteOffset ];
this._handleRequest({ "id" : wrappedBufferView.id,
this._handleRequest({ "id" : wrappedBufferView.id,
"range" : range,
"type" : buffer.description.type,
"path" : buffer.description.path,
......@@ -189,14 +189,14 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
value: function(wrappedBufferView, delegate, ctx) {
var savedBuffer = this._getResource(wrappedBufferView.id);
if (savedBuffer) {
return savedBuffer;
} else {
this._handleWrappedBufferViewResourceLoading(wrappedBufferView, delegate, ctx);
}
var savedBuffer = this._getResource(wrappedBufferView.id);
if (savedBuffer) {
return savedBuffer;
} else {
this._handleWrappedBufferViewResourceLoading(wrappedBufferView, delegate, ctx);
}
return null;
return null;
}
},
......@@ -204,17 +204,17 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
value: function(request, delegate, ctx) {
request.delegate = delegate;
request.ctx = ctx;
request.delegate = delegate;
request.ctx = ctx;
this._handleRequest({ "id" : request.id,
this._handleRequest({ "id" : request.id,
"path" : request.path,
"range" : [ 0 ],
"type" : "text",
"delegate" : delegate,
"ctx" : ctx }, null);
return null;
}
return null;
}
},
});
......@@ -215,7 +215,7 @@ THREE.SVGRenderer = function () {
var x = _vector3.x * _svgWidthHalf;
var y = - _vector3.y * _svgHeightHalf;
var node = object.node;
var node = object.node;
node.setAttribute( 'transform', 'translate(' + x + ',' + y + ')' );
_svg.appendChild( node );
......
......@@ -404,8 +404,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
+ (material.palette[cIndex + 2] * tdata[tIndex + 2]);
if (opaci < 250) {
var backColor = buffer[ colorOffset ] << 24 + buffer[ colorOffset + 1 ] << 16 + buffer[ colorOffset + 2 ] << 8;
foreColor = foreColor * opaci + backColor * (1 - opaci);
var backColor = buffer[ colorOffset ] << 24 + buffer[ colorOffset + 1 ] << 16 + buffer[ colorOffset + 2 ] << 8;
foreColor = foreColor * opaci + backColor * (1 - opaci);
}
buffer[ colorOffset ] = (foreColor & 0xff0000) >> 16;
......
此差异已折叠。
......@@ -182,11 +182,11 @@ THREE.FontUtils = {
var t = i2 / divisions;
var tx = THREE.Shape.Utils.b2( t, cpx0, cpx1, cpx );
var ty = THREE.Shape.Utils.b2( t, cpy0, cpy1, cpy );
}
}
}
}
break;
break;
case 'b':
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册