Prechádzať zdrojové kódy

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

kchapelier 8 rokov pred
rodič
commit
f5cd1d1671

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

@@ -243,6 +243,8 @@
 			var loader = new THREE.FileLoader( scope.manager );
 			loader.setResponseType( 'arraybuffer' );
 
+			url = url.replace( /\*/g, isBigEndianPlatform() ? 'be' : 'le' );
+
 			loader.load( url, function ( 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 ) {
 
 			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 {
 				color:#FFFFFF;
 				text-transform: uppercase;
-				display:inline-block;
-				min-width:120px;
 			}
 
 			.models a, .models a:visited {
 				color:#FFFFFF;
-				margin-right:12px;
+				margin-left:12px;
 				text-decoration: none;
 			}
 
@@ -59,18 +57,17 @@
 
 
 		<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 class="notes">
 			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>
 			<a href="https://github.com/kchapelier/PRWM" target="_blank">Specifications and implementations</a>
 		</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 );