TDSLoader.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. ( function () {
  2. /**
  3. * Autodesk 3DS three.js file loader, based on lib3ds.
  4. *
  5. * Loads geometry with uv and materials basic properties with texture support.
  6. *
  7. * @class TDSLoader
  8. * @constructor
  9. */
  10. class TDSLoader extends THREE.Loader {
  11. constructor( manager ) {
  12. super( manager );
  13. this.debug = false;
  14. this.group = null;
  15. this.materials = [];
  16. this.meshes = [];
  17. }
  18. /**
  19. * Load 3ds file from url.
  20. *
  21. * @method load
  22. * @param {[type]} url URL for the file.
  23. * @param {Function} onLoad onLoad callback, receives group Object3D as argument.
  24. * @param {Function} onProgress onProgress callback.
  25. * @param {Function} onError onError callback.
  26. */
  27. load( url, onLoad, onProgress, onError ) {
  28. const scope = this;
  29. const path = this.path === '' ? THREE.LoaderUtils.extractUrlBase( url ) : this.path;
  30. const loader = new THREE.FileLoader( this.manager );
  31. loader.setPath( this.path );
  32. loader.setResponseType( 'arraybuffer' );
  33. loader.setRequestHeader( this.requestHeader );
  34. loader.setWithCredentials( this.withCredentials );
  35. loader.load( url, function ( data ) {
  36. try {
  37. onLoad( scope.parse( data, path ) );
  38. } catch ( e ) {
  39. if ( onError ) {
  40. onError( e );
  41. } else {
  42. console.error( e );
  43. }
  44. scope.manager.itemError( url );
  45. }
  46. }, onProgress, onError );
  47. }
  48. /**
  49. * Parse arraybuffer data and load 3ds file.
  50. *
  51. * @method parse
  52. * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
  53. * @param {String} path Path for external resources.
  54. * @return {Group} THREE.Group loaded from 3ds file.
  55. */
  56. parse( arraybuffer, path ) {
  57. this.group = new THREE.Group();
  58. this.materials = [];
  59. this.meshes = [];
  60. this.readFile( arraybuffer, path );
  61. for ( let i = 0; i < this.meshes.length; i ++ ) {
  62. this.group.add( this.meshes[ i ] );
  63. }
  64. return this.group;
  65. }
  66. /**
  67. * Decode file content to read 3ds data.
  68. *
  69. * @method readFile
  70. * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
  71. * @param {String} path Path for external resources.
  72. */
  73. readFile( arraybuffer, path ) {
  74. const data = new DataView( arraybuffer );
  75. const chunk = new Chunk( data, 0, this.debugMessage );
  76. if ( chunk.id === MLIBMAGIC || chunk.id === CMAGIC || chunk.id === M3DMAGIC ) {
  77. let next = chunk.readChunk();
  78. while ( next ) {
  79. if ( next.id === M3D_VERSION ) {
  80. const version = next.readDWord();
  81. this.debugMessage( '3DS file version: ' + version );
  82. } else if ( next.id === MDATA ) {
  83. this.readMeshData( next, path );
  84. } else {
  85. this.debugMessage( 'Unknown main chunk: ' + next.hexId );
  86. }
  87. next = chunk.readChunk();
  88. }
  89. }
  90. this.debugMessage( 'Parsed ' + this.meshes.length + ' meshes' );
  91. }
  92. /**
  93. * Read mesh data chunk.
  94. *
  95. * @method readMeshData
  96. * @param {Chunk} chunk to read mesh from
  97. * @param {String} path Path for external resources.
  98. */
  99. readMeshData( chunk, path ) {
  100. let next = chunk.readChunk();
  101. while ( next ) {
  102. if ( next.id === MESH_VERSION ) {
  103. const version = + next.readDWord();
  104. this.debugMessage( 'Mesh Version: ' + version );
  105. } else if ( next.id === MASTER_SCALE ) {
  106. const scale = next.readFloat();
  107. this.debugMessage( 'Master scale: ' + scale );
  108. this.group.scale.set( scale, scale, scale );
  109. } else if ( next.id === NAMED_OBJECT ) {
  110. this.debugMessage( 'Named Object' );
  111. this.readNamedObject( next );
  112. } else if ( next.id === MAT_ENTRY ) {
  113. this.debugMessage( 'Material' );
  114. this.readMaterialEntry( next, path );
  115. } else {
  116. this.debugMessage( 'Unknown MDATA chunk: ' + next.hexId );
  117. }
  118. next = chunk.readChunk();
  119. }
  120. }
  121. /**
  122. * Read named object chunk.
  123. *
  124. * @method readNamedObject
  125. * @param {Chunk} chunk Chunk in use.
  126. */
  127. readNamedObject( chunk ) {
  128. const name = chunk.readString();
  129. let next = chunk.readChunk();
  130. while ( next ) {
  131. if ( next.id === N_TRI_OBJECT ) {
  132. const mesh = this.readMesh( next );
  133. mesh.name = name;
  134. this.meshes.push( mesh );
  135. } else {
  136. this.debugMessage( 'Unknown named object chunk: ' + next.hexId );
  137. }
  138. next = chunk.readChunk();
  139. }
  140. }
  141. /**
  142. * Read material data chunk and add it to the material list.
  143. *
  144. * @method readMaterialEntry
  145. * @param {Chunk} chunk Chunk in use.
  146. * @param {String} path Path for external resources.
  147. */
  148. readMaterialEntry( chunk, path ) {
  149. let next = chunk.readChunk();
  150. const material = new THREE.MeshPhongMaterial();
  151. while ( next ) {
  152. if ( next.id === MAT_NAME ) {
  153. material.name = next.readString();
  154. this.debugMessage( ' Name: ' + material.name );
  155. } else if ( next.id === MAT_WIRE ) {
  156. this.debugMessage( ' Wireframe' );
  157. material.wireframe = true;
  158. } else if ( next.id === MAT_WIRE_SIZE ) {
  159. const value = next.readByte();
  160. material.wireframeLinewidth = value;
  161. this.debugMessage( ' Wireframe Thickness: ' + value );
  162. } else if ( next.id === MAT_TWO_SIDE ) {
  163. material.side = THREE.DoubleSide;
  164. this.debugMessage( ' DoubleSided' );
  165. } else if ( next.id === MAT_ADDITIVE ) {
  166. this.debugMessage( ' Additive Blending' );
  167. material.blending = THREE.AdditiveBlending;
  168. } else if ( next.id === MAT_DIFFUSE ) {
  169. this.debugMessage( ' Diffuse THREE.Color' );
  170. material.color = this.readColor( next );
  171. } else if ( next.id === MAT_SPECULAR ) {
  172. this.debugMessage( ' Specular THREE.Color' );
  173. material.specular = this.readColor( next );
  174. } else if ( next.id === MAT_AMBIENT ) {
  175. this.debugMessage( ' Ambient color' );
  176. material.color = this.readColor( next );
  177. } else if ( next.id === MAT_SHININESS ) {
  178. const shininess = this.readPercentage( next );
  179. material.shininess = shininess * 100;
  180. this.debugMessage( ' Shininess : ' + shininess );
  181. } else if ( next.id === MAT_TRANSPARENCY ) {
  182. const transparency = this.readPercentage( next );
  183. material.opacity = 1 - transparency;
  184. this.debugMessage( ' Transparency : ' + transparency );
  185. material.transparent = material.opacity < 1 ? true : false;
  186. } else if ( next.id === MAT_TEXMAP ) {
  187. this.debugMessage( ' ColorMap' );
  188. material.map = this.readMap( next, path );
  189. } else if ( next.id === MAT_BUMPMAP ) {
  190. this.debugMessage( ' BumpMap' );
  191. material.bumpMap = this.readMap( next, path );
  192. } else if ( next.id === MAT_OPACMAP ) {
  193. this.debugMessage( ' OpacityMap' );
  194. material.alphaMap = this.readMap( next, path );
  195. } else if ( next.id === MAT_SPECMAP ) {
  196. this.debugMessage( ' SpecularMap' );
  197. material.specularMap = this.readMap( next, path );
  198. } else {
  199. this.debugMessage( ' Unknown material chunk: ' + next.hexId );
  200. }
  201. next = chunk.readChunk();
  202. }
  203. this.materials[ material.name ] = material;
  204. }
  205. /**
  206. * Read mesh data chunk.
  207. *
  208. * @method readMesh
  209. * @param {Chunk} chunk Chunk in use.
  210. * @return {Mesh} The parsed mesh.
  211. */
  212. readMesh( chunk ) {
  213. let next = chunk.readChunk();
  214. const geometry = new THREE.BufferGeometry();
  215. const material = new THREE.MeshPhongMaterial();
  216. const mesh = new THREE.Mesh( geometry, material );
  217. mesh.name = 'mesh';
  218. while ( next ) {
  219. if ( next.id === POINT_ARRAY ) {
  220. const points = next.readWord();
  221. this.debugMessage( ' Vertex: ' + points ); //BufferGeometry
  222. const vertices = [];
  223. for ( let i = 0; i < points; i ++ ) {
  224. vertices.push( next.readFloat() );
  225. vertices.push( next.readFloat() );
  226. vertices.push( next.readFloat() );
  227. }
  228. geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
  229. } else if ( next.id === FACE_ARRAY ) {
  230. this.readFaceArray( next, mesh );
  231. } else if ( next.id === TEX_VERTS ) {
  232. const texels = next.readWord();
  233. this.debugMessage( ' UV: ' + texels ); //BufferGeometry
  234. const uvs = [];
  235. for ( let i = 0; i < texels; i ++ ) {
  236. uvs.push( next.readFloat() );
  237. uvs.push( next.readFloat() );
  238. }
  239. geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
  240. } else if ( next.id === MESH_MATRIX ) {
  241. this.debugMessage( ' Tranformation Matrix (TODO)' );
  242. const values = [];
  243. for ( let i = 0; i < 12; i ++ ) {
  244. values[ i ] = next.readFloat();
  245. }
  246. const matrix = new THREE.Matrix4(); //X Line
  247. matrix.elements[ 0 ] = values[ 0 ];
  248. matrix.elements[ 1 ] = values[ 6 ];
  249. matrix.elements[ 2 ] = values[ 3 ];
  250. matrix.elements[ 3 ] = values[ 9 ]; //Y Line
  251. matrix.elements[ 4 ] = values[ 2 ];
  252. matrix.elements[ 5 ] = values[ 8 ];
  253. matrix.elements[ 6 ] = values[ 5 ];
  254. matrix.elements[ 7 ] = values[ 11 ]; //Z Line
  255. matrix.elements[ 8 ] = values[ 1 ];
  256. matrix.elements[ 9 ] = values[ 7 ];
  257. matrix.elements[ 10 ] = values[ 4 ];
  258. matrix.elements[ 11 ] = values[ 10 ]; //W Line
  259. matrix.elements[ 12 ] = 0;
  260. matrix.elements[ 13 ] = 0;
  261. matrix.elements[ 14 ] = 0;
  262. matrix.elements[ 15 ] = 1;
  263. matrix.transpose();
  264. const inverse = new THREE.Matrix4();
  265. inverse.copy( matrix ).invert();
  266. geometry.applyMatrix4( inverse );
  267. matrix.decompose( mesh.position, mesh.quaternion, mesh.scale );
  268. } else {
  269. this.debugMessage( ' Unknown mesh chunk: ' + next.hexId );
  270. }
  271. next = chunk.readChunk();
  272. }
  273. geometry.computeVertexNormals();
  274. return mesh;
  275. }
  276. /**
  277. * Read face array data chunk.
  278. *
  279. * @method readFaceArray
  280. * @param {Chunk} chunk Chunk in use.
  281. * @param {Mesh} mesh THREE.Mesh to be filled with the data read.
  282. */
  283. readFaceArray( chunk, mesh ) {
  284. const faces = chunk.readWord();
  285. this.debugMessage( ' Faces: ' + faces );
  286. const index = [];
  287. for ( let i = 0; i < faces; ++ i ) {
  288. index.push( chunk.readWord(), chunk.readWord(), chunk.readWord() );
  289. chunk.readWord(); // visibility
  290. }
  291. mesh.geometry.setIndex( index ); //The rest of the FACE_ARRAY chunk is subchunks
  292. let materialIndex = 0;
  293. let start = 0;
  294. while ( ! chunk.endOfChunk ) {
  295. const subchunk = chunk.readChunk();
  296. if ( subchunk.id === MSH_MAT_GROUP ) {
  297. this.debugMessage( ' Material THREE.Group' );
  298. const group = this.readMaterialGroup( subchunk );
  299. const count = group.index.length * 3; // assuming successive indices
  300. mesh.geometry.addGroup( start, count, materialIndex );
  301. start += count;
  302. materialIndex ++;
  303. const material = this.materials[ group.name ];
  304. if ( Array.isArray( mesh.material ) === false ) mesh.material = [];
  305. if ( material !== undefined ) {
  306. mesh.material.push( material );
  307. }
  308. } else {
  309. this.debugMessage( ' Unknown face array chunk: ' + subchunk.hexId );
  310. }
  311. }
  312. if ( mesh.material.length === 1 ) mesh.material = mesh.material[ 0 ]; // for backwards compatibility
  313. }
  314. /**
  315. * Read texture map data chunk.
  316. *
  317. * @method readMap
  318. * @param {Chunk} chunk Chunk in use.
  319. * @param {String} path Path for external resources.
  320. * @return {Texture} Texture read from this data chunk.
  321. */
  322. readMap( chunk, path ) {
  323. let next = chunk.readChunk();
  324. let texture = {};
  325. const loader = new THREE.TextureLoader( this.manager );
  326. loader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
  327. while ( next ) {
  328. if ( next.id === MAT_MAPNAME ) {
  329. const name = next.readString();
  330. texture = loader.load( name );
  331. this.debugMessage( ' File: ' + path + name );
  332. } else if ( next.id === MAT_MAP_UOFFSET ) {
  333. texture.offset.x = next.readFloat();
  334. this.debugMessage( ' OffsetX: ' + texture.offset.x );
  335. } else if ( next.id === MAT_MAP_VOFFSET ) {
  336. texture.offset.y = next.readFloat();
  337. this.debugMessage( ' OffsetY: ' + texture.offset.y );
  338. } else if ( next.id === MAT_MAP_USCALE ) {
  339. texture.repeat.x = next.readFloat();
  340. this.debugMessage( ' RepeatX: ' + texture.repeat.x );
  341. } else if ( next.id === MAT_MAP_VSCALE ) {
  342. texture.repeat.y = next.readFloat();
  343. this.debugMessage( ' RepeatY: ' + texture.repeat.y );
  344. } else {
  345. this.debugMessage( ' Unknown map chunk: ' + next.hexId );
  346. }
  347. next = chunk.readChunk();
  348. }
  349. return texture;
  350. }
  351. /**
  352. * Read material group data chunk.
  353. *
  354. * @method readMaterialGroup
  355. * @param {Chunk} chunk Chunk in use.
  356. * @return {Object} Object with name and index of the object.
  357. */
  358. readMaterialGroup( chunk ) {
  359. const name = chunk.readString();
  360. const numFaces = chunk.readWord();
  361. this.debugMessage( ' Name: ' + name );
  362. this.debugMessage( ' Faces: ' + numFaces );
  363. const index = [];
  364. for ( let i = 0; i < numFaces; ++ i ) {
  365. index.push( chunk.readWord() );
  366. }
  367. return {
  368. name: name,
  369. index: index
  370. };
  371. }
  372. /**
  373. * Read a color value.
  374. *
  375. * @method readColor
  376. * @param {Chunk} chunk Chunk.
  377. * @return {Color} THREE.Color value read..
  378. */
  379. readColor( chunk ) {
  380. const subChunk = chunk.readChunk();
  381. const color = new THREE.Color();
  382. if ( subChunk.id === COLOR_24 || subChunk.id === LIN_COLOR_24 ) {
  383. const r = subChunk.readByte();
  384. const g = subChunk.readByte();
  385. const b = subChunk.readByte();
  386. color.setRGB( r / 255, g / 255, b / 255 );
  387. this.debugMessage( ' THREE.Color: ' + color.r + ', ' + color.g + ', ' + color.b );
  388. } else if ( subChunk.id === COLOR_F || subChunk.id === LIN_COLOR_F ) {
  389. const r = subChunk.readFloat();
  390. const g = subChunk.readFloat();
  391. const b = subChunk.readFloat();
  392. color.setRGB( r, g, b );
  393. this.debugMessage( ' THREE.Color: ' + color.r + ', ' + color.g + ', ' + color.b );
  394. } else {
  395. this.debugMessage( ' Unknown color chunk: ' + subChunk.hexId );
  396. }
  397. return color;
  398. }
  399. /**
  400. * Read percentage value.
  401. *
  402. * @method readPercentage
  403. * @param {Chunk} chunk Chunk to read data from.
  404. * @return {Number} Data read from the dataview.
  405. */
  406. readPercentage( chunk ) {
  407. const subChunk = chunk.readChunk();
  408. switch ( subChunk.id ) {
  409. case INT_PERCENTAGE:
  410. return subChunk.readShort() / 100;
  411. break;
  412. case FLOAT_PERCENTAGE:
  413. return subChunk.readFloat();
  414. break;
  415. default:
  416. this.debugMessage( ' Unknown percentage chunk: ' + subChunk.hexId );
  417. return 0;
  418. }
  419. }
  420. /**
  421. * Print debug message to the console.
  422. *
  423. * Is controlled by a flag to show or hide debug messages.
  424. *
  425. * @method debugMessage
  426. * @param {Object} message Debug message to print to the console.
  427. */
  428. debugMessage( message ) {
  429. if ( this.debug ) {
  430. console.log( message );
  431. }
  432. }
  433. }
  434. /** Read data/sub-chunks from chunk */
  435. class Chunk {
  436. /**
  437. * Create a new chunk
  438. *
  439. * @class Chunk
  440. * @param {DataView} data DataView to read from.
  441. * @param {Number} position in data.
  442. * @param {Function} debugMessage logging callback.
  443. */
  444. constructor( data, position, debugMessage ) {
  445. this.data = data; // the offset to the begin of this chunk
  446. this.offset = position; // the current reading position
  447. this.position = position;
  448. this.debugMessage = debugMessage;
  449. if ( this.debugMessage instanceof Function ) {
  450. this.debugMessage = function () {};
  451. }
  452. this.id = this.readWord();
  453. this.size = this.readDWord();
  454. this.end = this.offset + this.size;
  455. if ( this.end > data.byteLength ) {
  456. this.debugMessage( 'Bad chunk size for chunk at ' + position );
  457. }
  458. }
  459. /**
  460. * read a sub cchunk.
  461. *
  462. * @method readChunk
  463. * @return {Chunk | null} next sub chunk
  464. */
  465. readChunk() {
  466. if ( this.endOfChunk ) {
  467. return null;
  468. }
  469. try {
  470. const next = new Chunk( this.data, this.position, this.debugMessage );
  471. this.position += next.size;
  472. return next;
  473. } catch ( e ) {
  474. this.debugMessage( 'Unable to read chunk at ' + this.position );
  475. return null;
  476. }
  477. }
  478. /**
  479. * return the ID of this chunk as Hex
  480. *
  481. * @method idToString
  482. * @return {String} hex-string of id
  483. */
  484. get hexId() {
  485. return this.id.toString( 16 );
  486. }
  487. get endOfChunk() {
  488. return this.position >= this.end;
  489. }
  490. /**
  491. * Read byte value.
  492. *
  493. * @method readByte
  494. * @return {Number} Data read from the dataview.
  495. */
  496. readByte() {
  497. const v = this.data.getUint8( this.position, true );
  498. this.position += 1;
  499. return v;
  500. }
  501. /**
  502. * Read 32 bit float value.
  503. *
  504. * @method readFloat
  505. * @return {Number} Data read from the dataview.
  506. */
  507. readFloat() {
  508. try {
  509. const v = this.data.getFloat32( this.position, true );
  510. this.position += 4;
  511. return v;
  512. } catch ( e ) {
  513. this.debugMessage( e + ' ' + this.position + ' ' + this.data.byteLength );
  514. return 0;
  515. }
  516. }
  517. /**
  518. * Read 32 bit signed integer value.
  519. *
  520. * @method readInt
  521. * @return {Number} Data read from the dataview.
  522. */
  523. readInt() {
  524. const v = this.data.getInt32( this.position, true );
  525. this.position += 4;
  526. return v;
  527. }
  528. /**
  529. * Read 16 bit signed integer value.
  530. *
  531. * @method readShort
  532. * @return {Number} Data read from the dataview.
  533. */
  534. readShort() {
  535. const v = this.data.getInt16( this.position, true );
  536. this.position += 2;
  537. return v;
  538. }
  539. /**
  540. * Read 64 bit unsigned integer value.
  541. *
  542. * @method readDWord
  543. * @return {Number} Data read from the dataview.
  544. */
  545. readDWord() {
  546. const v = this.data.getUint32( this.position, true );
  547. this.position += 4;
  548. return v;
  549. }
  550. /**
  551. * Read 32 bit unsigned integer value.
  552. *
  553. * @method readWord
  554. * @return {Number} Data read from the dataview.
  555. */
  556. readWord() {
  557. const v = this.data.getUint16( this.position, true );
  558. this.position += 2;
  559. return v;
  560. }
  561. /**
  562. * Read NULL terminated ASCII string value from chunk-pos.
  563. *
  564. * @method readString
  565. * @return {String} Data read from the dataview.
  566. */
  567. readString() {
  568. let s = '';
  569. let c = this.readByte();
  570. while ( c ) {
  571. s += String.fromCharCode( c );
  572. c = this.readByte();
  573. }
  574. return s;
  575. }
  576. } // const NULL_CHUNK = 0x0000;
  577. const M3DMAGIC = 0x4D4D; // const SMAGIC = 0x2D2D;
  578. // const LMAGIC = 0x2D3D;
  579. const MLIBMAGIC = 0x3DAA; // const MATMAGIC = 0x3DFF;
  580. const CMAGIC = 0xC23D;
  581. const M3D_VERSION = 0x0002; // const M3D_KFVERSION = 0x0005;
  582. const COLOR_F = 0x0010;
  583. const COLOR_24 = 0x0011;
  584. const LIN_COLOR_24 = 0x0012;
  585. const LIN_COLOR_F = 0x0013;
  586. const INT_PERCENTAGE = 0x0030;
  587. const FLOAT_PERCENTAGE = 0x0031;
  588. const MDATA = 0x3D3D;
  589. const MESH_VERSION = 0x3D3E;
  590. const MASTER_SCALE = 0x0100; // const LO_SHADOW_BIAS = 0x1400;
  591. // const HI_SHADOW_BIAS = 0x1410;
  592. // const SHADOW_MAP_SIZE = 0x1420;
  593. // const SHADOW_SAMPLES = 0x1430;
  594. // const SHADOW_RANGE = 0x1440;
  595. // const SHADOW_FILTER = 0x1450;
  596. // const RAY_BIAS = 0x1460;
  597. // const O_CONSTS = 0x1500;
  598. // const AMBIENT_LIGHT = 0x2100;
  599. // const BIT_MAP = 0x1100;
  600. // const SOLID_BGND = 0x1200;
  601. // const V_GRADIENT = 0x1300;
  602. // const USE_BIT_MAP = 0x1101;
  603. // const USE_SOLID_BGND = 0x1201;
  604. // const USE_V_GRADIENT = 0x1301;
  605. // const FOG = 0x2200;
  606. // const FOG_BGND = 0x2210;
  607. // const LAYER_FOG = 0x2302;
  608. // const DISTANCE_CUE = 0x2300;
  609. // const DCUE_BGND = 0x2310;
  610. // const USE_FOG = 0x2201;
  611. // const USE_LAYER_FOG = 0x2303;
  612. // const USE_DISTANCE_CUE = 0x2301;
  613. const MAT_ENTRY = 0xAFFF;
  614. const MAT_NAME = 0xA000;
  615. const MAT_AMBIENT = 0xA010;
  616. const MAT_DIFFUSE = 0xA020;
  617. const MAT_SPECULAR = 0xA030;
  618. const MAT_SHININESS = 0xA040; // const MAT_SHIN2PCT = 0xA041;
  619. const MAT_TRANSPARENCY = 0xA050; // const MAT_XPFALL = 0xA052;
  620. // const MAT_USE_XPFALL = 0xA240;
  621. // const MAT_REFBLUR = 0xA053;
  622. // const MAT_SHADING = 0xA100;
  623. // const MAT_USE_REFBLUR = 0xA250;
  624. // const MAT_SELF_ILLUM = 0xA084;
  625. const MAT_TWO_SIDE = 0xA081; // const MAT_DECAL = 0xA082;
  626. const MAT_ADDITIVE = 0xA083;
  627. const MAT_WIRE = 0xA085; // const MAT_FACEMAP = 0xA088;
  628. // const MAT_TRANSFALLOFF_IN = 0xA08A;
  629. // const MAT_PHONGSOFT = 0xA08C;
  630. // const MAT_WIREABS = 0xA08E;
  631. const MAT_WIRE_SIZE = 0xA087;
  632. const MAT_TEXMAP = 0xA200; // const MAT_SXP_TEXT_DATA = 0xA320;
  633. // const MAT_TEXMASK = 0xA33E;
  634. // const MAT_SXP_TEXTMASK_DATA = 0xA32A;
  635. // const MAT_TEX2MAP = 0xA33A;
  636. // const MAT_SXP_TEXT2_DATA = 0xA321;
  637. // const MAT_TEX2MASK = 0xA340;
  638. // const MAT_SXP_TEXT2MASK_DATA = 0xA32C;
  639. const MAT_OPACMAP = 0xA210; // const MAT_SXP_OPAC_DATA = 0xA322;
  640. // const MAT_OPACMASK = 0xA342;
  641. // const MAT_SXP_OPACMASK_DATA = 0xA32E;
  642. const MAT_BUMPMAP = 0xA230; // const MAT_SXP_BUMP_DATA = 0xA324;
  643. // const MAT_BUMPMASK = 0xA344;
  644. // const MAT_SXP_BUMPMASK_DATA = 0xA330;
  645. const MAT_SPECMAP = 0xA204; // const MAT_SXP_SPEC_DATA = 0xA325;
  646. // const MAT_SPECMASK = 0xA348;
  647. // const MAT_SXP_SPECMASK_DATA = 0xA332;
  648. // const MAT_SHINMAP = 0xA33C;
  649. // const MAT_SXP_SHIN_DATA = 0xA326;
  650. // const MAT_SHINMASK = 0xA346;
  651. // const MAT_SXP_SHINMASK_DATA = 0xA334;
  652. // const MAT_SELFIMAP = 0xA33D;
  653. // const MAT_SXP_SELFI_DATA = 0xA328;
  654. // const MAT_SELFIMASK = 0xA34A;
  655. // const MAT_SXP_SELFIMASK_DATA = 0xA336;
  656. // const MAT_REFLMAP = 0xA220;
  657. // const MAT_REFLMASK = 0xA34C;
  658. // const MAT_SXP_REFLMASK_DATA = 0xA338;
  659. // const MAT_ACUBIC = 0xA310;
  660. const MAT_MAPNAME = 0xA300; // const MAT_MAP_TILING = 0xA351;
  661. // const MAT_MAP_TEXBLUR = 0xA353;
  662. const MAT_MAP_USCALE = 0xA354;
  663. const MAT_MAP_VSCALE = 0xA356;
  664. const MAT_MAP_UOFFSET = 0xA358;
  665. const MAT_MAP_VOFFSET = 0xA35A; // const MAT_MAP_ANG = 0xA35C;
  666. // const MAT_MAP_COL1 = 0xA360;
  667. // const MAT_MAP_COL2 = 0xA362;
  668. // const MAT_MAP_RCOL = 0xA364;
  669. // const MAT_MAP_GCOL = 0xA366;
  670. // const MAT_MAP_BCOL = 0xA368;
  671. const NAMED_OBJECT = 0x4000; // const N_DIRECT_LIGHT = 0x4600;
  672. // const DL_OFF = 0x4620;
  673. // const DL_OUTER_RANGE = 0x465A;
  674. // const DL_INNER_RANGE = 0x4659;
  675. // const DL_MULTIPLIER = 0x465B;
  676. // const DL_EXCLUDE = 0x4654;
  677. // const DL_ATTENUATE = 0x4625;
  678. // const DL_SPOTLIGHT = 0x4610;
  679. // const DL_SPOT_ROLL = 0x4656;
  680. // const DL_SHADOWED = 0x4630;
  681. // const DL_LOCAL_SHADOW2 = 0x4641;
  682. // const DL_SEE_CONE = 0x4650;
  683. // const DL_SPOT_RECTANGULAR = 0x4651;
  684. // const DL_SPOT_ASPECT = 0x4657;
  685. // const DL_SPOT_PROJECTOR = 0x4653;
  686. // const DL_SPOT_OVERSHOOT = 0x4652;
  687. // const DL_RAY_BIAS = 0x4658;
  688. // const DL_RAYSHAD = 0x4627;
  689. // const N_CAMERA = 0x4700;
  690. // const CAM_SEE_CONE = 0x4710;
  691. // const CAM_RANGES = 0x4720;
  692. // const OBJ_HIDDEN = 0x4010;
  693. // const OBJ_VIS_LOFTER = 0x4011;
  694. // const OBJ_DOESNT_CAST = 0x4012;
  695. // const OBJ_DONT_RECVSHADOW = 0x4017;
  696. // const OBJ_MATTE = 0x4013;
  697. // const OBJ_FAST = 0x4014;
  698. // const OBJ_PROCEDURAL = 0x4015;
  699. // const OBJ_FROZEN = 0x4016;
  700. const N_TRI_OBJECT = 0x4100;
  701. const POINT_ARRAY = 0x4110; // const POINT_FLAG_ARRAY = 0x4111;
  702. const FACE_ARRAY = 0x4120;
  703. const MSH_MAT_GROUP = 0x4130; // const SMOOTH_GROUP = 0x4150;
  704. // const MSH_BOXMAP = 0x4190;
  705. const TEX_VERTS = 0x4140;
  706. const MESH_MATRIX = 0x4160; // const MESH_COLOR = 0x4165;
  707. THREE.TDSLoader = TDSLoader;
  708. } )();