Ver código fonte

Merge pull request #10181 from sunag/sea3d_1.8.1

sea3d polyfill
Mr.doob 8 anos atrás
pai
commit
fb240ee6c5

+ 33 - 94
examples/js/loaders/sea3d/SEA3DLoader.js

@@ -5,6 +5,21 @@
 
 'use strict';
 
+//
+//	Polyfills
+//
+
+if (THREE.Float32BufferAttribute === undefined) {
+
+	THREE.Float32BufferAttribute = THREE.Float32Attribute;
+
+}
+
+//
+//
+//	SEA3D
+//
+
 THREE.SEA3D = function ( config ) {
 
 	this.config = {
@@ -522,8 +537,6 @@ Object.assign( THREE.SEA3D.Animator.prototype, {
 
 		if ( this.mixer ) THREE.SEA3D.AnimationHandler.removeAnimator( this );
 
-		//THREE.SEA3D.AnimationHandler.addAnimator( this ); //////////§§§§!!!
-
 		this.mixer = mixer;
 
 		this.relative = false;
@@ -536,10 +549,7 @@ Object.assign( THREE.SEA3D.Animator.prototype, {
 		this.animationsIndex = [];
 		this.animationsData = {};
 
-		// if no geometry animation
-		if ( this.geometry && this.geometry.animations === undefined ) return;
-
-		this.clips = this instanceof THREE.SEA3D.Animator ? this.clips : this.geometry.animations;
+		this.clips = ( this instanceof THREE.SEA3D.Animator ? this.clips : this.geometry.animations ) || [];
 
 		for ( var i = 0; i < this.clips.length; i ++ ) {
 
@@ -1743,19 +1753,8 @@ THREE.SEA3D.prototype.readGeometryBuffer = function ( sea ) {
 
 	if ( sea.joint ) {
 
-		if ( THREE.Float32BufferAttribute ) {
-
-			// three dev
-
-			geo.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( sea.joint, sea.jointPerVertex ) );
-			geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( sea.weight, sea.jointPerVertex ) );
-
-		} else {
-
-			geo.addAttribute( 'skinIndex', new THREE.Float32Attribute( sea.joint, sea.jointPerVertex ) );
-			geo.addAttribute( 'skinWeight', new THREE.Float32Attribute( sea.weight, sea.jointPerVertex ) );
-
-		}
+		geo.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( sea.joint, sea.jointPerVertex ) );
+		geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( sea.weight, sea.jointPerVertex ) );
 
 	}
 
@@ -1803,17 +1802,7 @@ THREE.SEA3D.prototype.readLine = function ( sea ) {
 	if ( sea.closed )
 		sea.vertex.push( sea.vertex[ 0 ], sea.vertex[ 1 ], sea.vertex[ 2 ] );
 
-	if ( THREE.Float32BufferAttribute ) {
-
-		// three dev
-
-		geo.addAttribute( 'position', new THREE.Float32BufferAttribute( sea.vertex, 3 ) );
-
-	} else {
-
-		geo.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( sea.vertex ), 3 ) );
-
-	}
+	geo.addAttribute( 'position', new THREE.Float32BufferAttribute( sea.vertex, 3 ) );
 
 	var line = new THREE.Line( geo, new THREE.LineBasicMaterial( { color: THREE.SEA3D.HELPER_COLOR, linewidth: 3 } ) );
 	line.name = sea.name;
@@ -2805,45 +2794,20 @@ THREE.SEA3D.prototype.readMorpher = function ( sea ) {
 
 	var attribs = { position: [] }, targets = [];
 
-	if ( THREE.Float32BufferAttribute ) {
-
-		// three dev
-
-		for ( var i = 0; i < sea.node.length; i ++ ) {
-
-			var node = sea.node[ i ];
+	for ( var i = 0; i < sea.node.length; i ++ ) {
 
-			attribs.position[ i ] = new THREE.Float32BufferAttribute( node.vertex, 3 );
+		var node = sea.node[ i ];
 
-			if ( node.normal ) {
+		attribs.position[ i ] = new THREE.Float32BufferAttribute( node.vertex, 3 );
 
-				attribs.normal = attribs.normal || [];
-				attribs.normal[ i ] = new THREE.Float32BufferAttribute( node.normal, 3 );
+		if ( node.normal ) {
 
-			}
-
-			targets[ i ] = { name: node.name };
+			attribs.normal = attribs.normal || [];
+			attribs.normal[ i ] = new THREE.Float32BufferAttribute( node.normal, 3 );
 
 		}
 
-	} else {
-
-		for ( var i = 0; i < sea.node.length; i ++ ) {
-
-			var node = sea.node[ i ];
-
-			attribs.position[ i ] = new THREE.Float32Attribute( new Float32Array( node.vertex ), 3 );
-
-			if ( node.normal ) {
-
-				attribs.normal = attribs.normal || [];
-				attribs.normal[ i ] = new THREE.Float32Attribute( new Float32Array( node.normal ), 3 );
-
-			}
-
-			targets[ i ] = { name: node.name };
-
-		}
+		targets[ i ] = { name: node.name };
 
 	}
 
@@ -2927,45 +2891,20 @@ THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) {
 
 	var attribs = { position: [] }, targets = [], animations = [], i, j, l;
 
-	if ( THREE.Float32BufferAttribute ) {
-
-		// three dev
-
-		for ( i = 0, l = sea.frame.length; i < l; i ++ ) {
+	for ( i = 0, l = sea.frame.length; i < l; i ++ ) {
 
-			var frame = sea.frame[ i ];
+		var frame = sea.frame[ i ];
 
-			attribs.position[ i ] = new THREE.Float32BufferAttribute( frame.vertex, 3 );
+		attribs.position[ i ] = new THREE.Float32BufferAttribute( frame.vertex, 3 );
 
-			if ( frame.normal ) {
+		if ( frame.normal ) {
 
-				attribs.normal = attribs.normal || [];
-				attribs.normal[ i ] = new THREE.Float32BufferAttribute( frame.normal, 3 );
-
-			}
-
-			targets[ i ] = { name: i };
+			attribs.normal = attribs.normal || [];
+			attribs.normal[ i ] = new THREE.Float32BufferAttribute( frame.normal, 3 );
 
 		}
 
-	} else {
-
-		for ( i = 0, l = sea.frame.length; i < l; i ++ ) {
-
-			var frame = sea.frame[ i ];
-
-			attribs.position[ i ] = new THREE.Float32Attribute( new Float32Array( frame.vertex ), 3 );
-
-			if ( frame.normal ) {
-
-				attribs.normal = attribs.normal || [];
-				attribs.normal[ i ] = new THREE.Float32Attribute( new Float32Array( frame.normal ), 3 );
-
-			}
-
-			targets[ i ] = { name: i };
-
-		}
+		targets[ i ] = { name: i };
 
 	}
 

+ 1 - 2
examples/webgl_loader_sea3d.html

@@ -28,8 +28,7 @@
 	</head>
 	<body>
 		<div id="info">
-			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Studio</a><br>
-			Asset by <a href="http://vhalldez.cgsociety.org/" style="color:#FFFFFF" target="_blank">Valdez Araujo</a>
+			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Studio</a>. Asset by <a href="http://vhalldez.cgsociety.org/" style="color:#FFFFFF" target="_blank">Valdez Araujo</a>
 		</div>
 
 		<script src="../build/three.js"></script>

+ 3 - 3
examples/webgl_loader_sea3d_hierarchy.html

@@ -28,9 +28,9 @@
 	</head>
 	<body>
 		<div id="info">
-			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Studio</a><br>
-			High geometry compression with <a href="https://github.com/amd/rest3d/tree/master/server/o3dgc" style="color:#FFFFFF" target="_blank">Open3DGC</a> and LZMA<br>
-			Asset by <a href="http://vhalldez.cgsociety.org/" style="color:#FFFFFF" target="_blank">Valdez Araujo</a>
+			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Studio</a>. Asset by <a href="http://vhalldez.cgsociety.org/" style="color:#FFFFFF" target="_blank">Valdez Araujo</a>
+			<br/>
+			<br/>High geometry compression with <a href="https://github.com/amd/rest3d/tree/master/server/o3dgc" style="color:#FFFFFF" target="_blank">Open3DGC</a> and LZMA<br>
 		</div>
 
 		<script src="../build/three.js"></script>

+ 3 - 2
examples/webgl_loader_sea3d_keyframe.html

@@ -28,8 +28,9 @@
 	</head>
 	<body>
 		<div id="info">
-			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a><br>
-			<div id="description">Click to play</div>
+			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a>
+			<br/>
+			<br/><div id="description">Click to play</div>
 		</div>
 
 		<script src="../build/three.js"></script>

+ 3 - 2
examples/webgl_loader_sea3d_morph.html

@@ -28,8 +28,9 @@
 	</head>
 	<body>
 		<div id="info">
-			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a><br>
-			<div id="description">Flag is Vertex Animation / Teapot is Morpher</div>
+			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a>
+			<br/>
+			<br/><div id="description">Flag is Vertex Animation / Teapot is Morpher</div>
 		</div>
 
 		<script src="../build/three.js"></script>

+ 2 - 1
examples/webgl_loader_sea3d_skinning.html

@@ -28,7 +28,8 @@
 	</head>
 	<body>
 		<div id="info">
-			<a href="http://threejs.org" target="_blank">three.js</a> - asset by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">sea3d</a>
+			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a>. Asset by <a href="http://www.turbosquid.com/3d-models/soccer-player-max-free/307330" style="color:#FFFFFF" target="_blank">Trivision</a>
+			<br/>
 			<br/>BoneObject: Object3D attached in a Bone
 			<br/>Left Click to hidden/show the hat - Right click to run
 			<br/><div id="playercount"></div>

+ 1 - 1
examples/webgl_loader_sea3d_sound.html

@@ -67,7 +67,7 @@
 	</head>
 	<body>
 		<div id="info">
-			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Studio</a><br>
+			<a href="http://threejs.org" target="_blank">Three.JS</a> - Exported by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Exporter</a> and edited by <a href="https://github.com/sunag/sea3d" style="color:#FFFFFF" target="_blank">SEA3D Studio</a>
 		</div>
 
 		<div id="blocker">