Browse Source

simplify the API by replacing * in the url by le or be depending on the platform's endianness

kchapelier 8 years ago
parent
commit
f5cd1d1671

+ 2 - 6
examples/js/loaders/PRWMLoader.js

@@ -243,6 +243,8 @@
 			var loader = new THREE.FileLoader( scope.manager );
 			var loader = new THREE.FileLoader( scope.manager );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setResponseType( 'arraybuffer' );
 
 
+			url = url.replace( /\*/g, isBigEndianPlatform() ? 'be' : 'le' );
+
 			loader.load( url, function ( arrayBuffer ) {
 			loader.load( url, function ( arrayBuffer ) {
 
 
 				onLoad( scope.parse( arrayBuffer ) );
 				onLoad( scope.parse( arrayBuffer ) );
@@ -251,12 +253,6 @@
 
 
 		},
 		},
 
 
-		loadBest: function ( urlLittleEndian, urlBigEndian, onLoad, onProgress, onError ) {
-
-			this.load( ( isBigEndianPlatform() ? urlBigEndian : urlLittleEndian ), onLoad, onProgress, onError );
-
-		},
-
 		parse: function ( arrayBuffer ) {
 		parse: function ( arrayBuffer ) {
 
 
 			console.time( 'PRWMLoader' );
 			console.time( 'PRWMLoader' );

+ 0 - 0
examples/models/prwm/faceted-nefertiti-BE.prwm → examples/models/prwm/faceted-nefertiti.be.prwm


+ 0 - 0
examples/models/prwm/faceted-nefertiti-LE.prwm → examples/models/prwm/faceted-nefertiti.le.prwm


+ 0 - 0
examples/models/prwm/smooth-suzanne-BE.prwm → examples/models/prwm/smooth-suzanne.be.prwm


+ 0 - 0
examples/models/prwm/smooth-suzanne-LE.prwm → examples/models/prwm/smooth-suzanne.le.prwm


+ 0 - 0
examples/models/prwm/vive-controller-BE.prwm → examples/models/prwm/vive-controller.be.prwm


+ 0 - 0
examples/models/prwm/vive-controller-LE.prwm → examples/models/prwm/vive-controller.le.prwm


+ 11 - 13
examples/webgl_loader_prwm.html

@@ -39,13 +39,11 @@
 			.models strong {
 			.models strong {
 				color:#FFFFFF;
 				color:#FFFFFF;
 				text-transform: uppercase;
 				text-transform: uppercase;
-				display:inline-block;
-				min-width:120px;
 			}
 			}
 
 
 			.models a, .models a:visited {
 			.models a, .models a:visited {
 				color:#FFFFFF;
 				color:#FFFFFF;
-				margin-right:12px;
+				margin-left:12px;
 				text-decoration: none;
 				text-decoration: none;
 			}
 			}
 
 
@@ -59,18 +57,17 @@
 
 
 
 
 		<div class="models">
 		<div class="models">
-			<strong>Little-Endian</strong>
-			<a class="model" href="./models/prwm/faceted-nefertiti-LE.prwm">Faceted Nefertiti</a>
-			<a class="model" href="./models/prwm/smooth-suzanne-LE.prwm">Smooth Suzanne</a>
-			<a class="model" href="./models/prwm/vive-controller-LE.prwm">Vive Controller</a><br>
-			<strong>Big-Endian</strong>
-			<a class="model" href="./models/prwm/faceted-nefertiti-BE.prwm">Faceted Nefertiti</a>
-			<a class="model" href="./models/prwm/smooth-suzanne-BE.prwm">Smooth Suzanne</a>
-			<a class="model" href="./models/prwm/vive-controller-BE.prwm">Vive Controller</a>
+			<strong>Models</strong>
+			<a class="model" href="models/prwm/faceted-nefertiti.*.prwm">Faceted Nefertiti</a>
+			<a class="model" href="models/prwm/smooth-suzanne.*.prwm">Smooth Suzanne</a>
+			<a class="model" href="models/prwm/vive-controller.*.prwm">Vive Controller</a>
 		</div>
 		</div>
 		<div class="notes">
 		<div class="notes">
 			The parsing of PRWM file is especially fast when the endianness of the file is the same as the endianness
 			The parsing of PRWM file is especially fast when the endianness of the file is the same as the endianness
-			of the client platform. This platform endianness is <strong id="endianness"></strong>.<br><br>
+			of the client platform. The loader will automatically replace the <strong>*</strong> in the model url
+			by either <strong>le</strong> or <strong>be</strong> depending on the client platform's endianness to
+			download the most appropriate file.<br><br>
+			This platform endianness is <strong id="endianness"></strong>.<br><br>
 			See your console for stats.<br><br>
 			See your console for stats.<br><br>
 			<a href="https://github.com/kchapelier/PRWM" target="_blank">Specifications and implementations</a>
 			<a href="https://github.com/kchapelier/PRWM" target="_blank">Specifications and implementations</a>
 		</div>
 		</div>
@@ -201,7 +198,8 @@
 
 
 				//
 				//
 
 
-				loadGeometry( './models/prwm/smooth-suzanne-LE.prwm' );
+				// * is automatically replaced by 'le' or 'be' depending on the client platform's endianness
+				loadGeometry( './models/prwm/smooth-suzanne.*.prwm' );
 
 
 				window.addEventListener( 'resize', onWindowResize, false );
 				window.addEventListener( 'resize', onWindowResize, false );