PageRenderTime 72ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/src/org/papervision3d/core/components/as3/flash9/PV3DColladaScene.as

http://github.com/tcha-tcho/EZFLAR
ActionScript | 730 lines | 453 code | 108 blank | 169 comment | 69 complexity | b81cf20a124f2ad561aa657562bc2553 MD5 | raw file
  1. /**
  2. * @author John Grden
  3. */
  4. package org.papervision3d.core.components.as3.flash9 {
  5. import flash.display.Sprite;
  6. import flash.events.Event;
  7. import flash.events.IOErrorEvent;
  8. import flash.events.ProgressEvent;
  9. import flash.events.TimerEvent;
  10. import flash.utils.Dictionary;
  11. import flash.utils.Timer;
  12. import org.papervision3d.core.components.as3.collections.MaterialsListItem;
  13. import org.papervision3d.core.components.as3.utils.ObjectController;
  14. import org.papervision3d.core.components.as3.utils.StageTools;
  15. import org.papervision3d.core.proto.MaterialObject3D;
  16. import org.papervision3d.events.FileLoadEvent;
  17. import org.papervision3d.materials.BitmapAssetMaterial;
  18. import org.papervision3d.materials.BitmapFileMaterial;
  19. import org.papervision3d.materials.BitmapMaterial;
  20. import org.papervision3d.materials.ColorMaterial;
  21. import org.papervision3d.materials.MovieAssetMaterial;
  22. import org.papervision3d.materials.MovieMaterial;
  23. import org.papervision3d.materials.utils.MaterialsList;
  24. import org.papervision3d.objects.DisplayObject3D;
  25. import org.papervision3d.objects.parsers.DAE;
  26. import com.blitzagency.xray.logger.util.PropertyTools;
  27. import fl.data.SimpleDataProvider;
  28. /**
  29. * Dispatched when the collada file and materials have been completely parsed and loaded.
  30. *
  31. * @eventType org.papervision3d.components.as3.flash9.PV3DColladaScene.SCENE_COMPLETE
  32. */
  33. [Event(name="sceneComplete", type="flash.events.Event")]
  34. /**
  35. * Dispatched while the collada file is loading.
  36. * <p>Event carries 2 properties:
  37. * <ul>
  38. * <li>1. bytesLoaded
  39. * <li>2. bytesTotal
  40. * </ul>
  41. * </p>
  42. * @eventType org.papervision3d.components.as3.flash9.PV3DColladaScene.SCENE_LOAD_PROGRESS
  43. */
  44. [Event(name="sceneLoadProgress", type="flash.events.Event")]
  45. /**
  46. * Dispatched when the collada object cannot load the file specified either because of security or non-existance
  47. * <p>
  48. * provides a property called "message" which is the actual load error initially received.
  49. * </p>
  50. * @eventType org.papervision3d.components.as3.flash9.PV3DColladaScene.SCENE_LOAD_ERROR
  51. */
  52. [Event(name="sceneLoadError", type="flash.events.Event")]
  53. /**
  54. * PV3DColladaScene is the main class for the Flash CS3 COLLADA component.
  55. * </p>
  56. * <p>It's main purpose is to provide the developer/designer with drag and drop functionality to render a COLLADA scene with a camera and Scene3D. Full access to a materials list and objects
  57. * is given through the api:
  58. * <ul>
  59. * <li>scene</li>
  60. * <li>camera</li>
  61. * <li>collada</li>
  62. * </ul>
  63. * </p>
  64. * <p>The component includes a Custom Panel via Windows>other panels>PV3DPanel</P>
  65. * <p>To use the component, drag it from the components list on to the stage in the Flash IDE. First, set the local directory by clicking on the folder icon in the Panel.
  66. * Then, select the DAE (COLLADA) file to use. At this point, you *should* see your 3D scene being rendered.
  67. * </p>
  68. * <p>You might have to play with the scale if you're not seeing the scene or camera Z (move it out more).
  69. * </p>
  70. * <p>If you textured your models with bitmaps in your 3D application, COLLADA retains those file paths and Papervision3D will attempt to dynamically load them for you IF you don't
  71. * provide a materials list. So, there is a good chance you'll see your scene fully textured once you've provided the local directory and file paths.
  72. * </p>
  73. * <p>If you provide a MaterialsList via the property inspector, there are 3 types supported:
  74. * <ul>
  75. * <li>Bitmap: BitmapAssetMaterial - a bitmap defined in the library</li>
  76. * <li>MovieClip: MovieAssetMaterial - a MovieClip defined in the library</li>
  77. * <li>File: BitmapFileMaterial - an external bitmap file</li>
  78. * </ul>
  79. *
  80. * </p>
  81. * @see org.papervision3d.core.components.as3.collections.MaterialsListItem
  82. */
  83. public class PV3DColladaScene extends PV3DScene3D
  84. {
  85. /**
  86. * @eventType sceneComplete
  87. */
  88. public static const SCENE_COMPLETE :String = "sceneComplete";
  89. /**
  90. * @eventType sceneLoadProgress
  91. */
  92. public static const SCENE_LOAD_PROGRESS :String = "sceneLoadProgress";
  93. /**
  94. * @eventType sceneLoadError
  95. */
  96. public static const SCENE_LOAD_ERROR :String = "sceneLoadError";
  97. /**
  98. * A boolean flag letting the component know whether or not to show trace output
  99. */
  100. public var debug :Boolean = true;
  101. private var _materialsList :MaterialsList = new MaterialsList();
  102. /**
  103. * The MaterialsList object that is used by the component if one is provided. This is set at design-time and is read-only at runtime
  104. */
  105. public function get materialsList():MaterialsList { return _materialsList; }
  106. private var _col :DAE;
  107. private var _colladaFile :String = "";
  108. private var _localPath :String = "";
  109. private var _sceneScale :Number = 0;
  110. private var rebuildCollada :Boolean = false;
  111. private var _rotationList :Object = {pitch:0, yaw:0, roll:0};
  112. private var _extMaterials :SimpleDataProvider = new SimpleDataProvider();
  113. private var fileLocation :String = "";
  114. private var materialsQue :Dictionary = new Dictionary();
  115. private var previewTimer :Timer = new Timer(25,0);
  116. /**
  117. * @private
  118. * @note Called when the component is actually running in a compiled SWF at runtime, rather than LivePreview
  119. * @param p_piSetting
  120. *
  121. */
  122. override public function set componentInspectorSetting(p_piSetting:Boolean):void
  123. {
  124. _componentInspectorSetting = p_piSetting;
  125. if(debug) log.debug("componentInspectorSetting", p_piSetting);
  126. if(!_componentInspectorSetting)
  127. {
  128. initApp();
  129. if(debug) log.debug("colladaFile?", colladaFile);
  130. if(debug) log.debug("isLivePreview?", isLivePreview);
  131. // just start by building materials and it'll light up from there.
  132. createMaterials();
  133. }
  134. }
  135. /**
  136. * @private
  137. */
  138. override public function get componentInspectorSetting():Boolean
  139. {
  140. return _componentInspectorSetting;
  141. }
  142. /**
  143. * The Papervision3D Collada object created for the component's use.
  144. * @return Collada object
  145. *
  146. */
  147. public function get collada():DAE
  148. {
  149. return _col;
  150. }
  151. public function set collada(col:DAE):void
  152. {
  153. _col = col;
  154. }
  155. /**
  156. * this fires after all of the properties have been updated. The Property Inspector (pi) sets all properties for a component even if only 1 is updated.
  157. * So, the modified LivePreviewParent I created makes this call to propertyInspectorSetting and passes a flag to let the component know that's its
  158. * ok to proceed with dealing with the changes.
  159. *
  160. * Changes have to be dealt with in a specific order. Materials, then collada WITH scale passed in the constructor, then rotation after collada is completely loaded.
  161. * @private
  162. */
  163. override public function set propertyInspectorSetting(p_piSetting:Boolean):void
  164. {
  165. trace(0);
  166. _propertyInspectorSetting = p_piSetting;
  167. if(!p_piSetting)
  168. {
  169. trace(1);
  170. // if we haven't initialized yet, do so
  171. if(!isAppInitialized) initApp();
  172. trace(2, isLivePreview);
  173. if(debug) log.debug("********** isLivePreview?", isLivePreview);
  174. trace(3, rebuildCollada, collada == null);
  175. if(rebuildCollada || collada == null)
  176. {
  177. if(debug) log.debug("GO CREATE MATERIALS");
  178. createMaterials();
  179. }else
  180. {
  181. if(debug) log.debug("GO update collada");
  182. finalizeColladaLoad();
  183. }
  184. }
  185. if(debug) log.debug("propertyInspectorSetting", p_piSetting);
  186. }
  187. /**
  188. * @private
  189. */
  190. override public function get propertyInspectorSetting():Boolean
  191. {
  192. return _propertyInspectorSetting;
  193. }
  194. [Inspectable (name="Scene Rotation", defaultValue=false, type="Boolean")]
  195. /**
  196. * Boolean flag indicating whether or not to add mouse drag/rotation abilities to the collada container. Clicking
  197. * yes will allow you to use simple dragging to rotate the scene.
  198. */
  199. public var sceneRotation :Boolean = true;
  200. [Inspectable (type="String", defaultValue="", name="Local Directory") ]
  201. /**
  202. * @private
  203. */
  204. public function set localPath(p_localPath:String):void
  205. {
  206. if(p_localPath != _localPath && p_localPath.length > 0)
  207. {
  208. p_localPath = p_localPath.split("\\").join("/");
  209. _localPath = p_localPath.substring(p_localPath.length-1) == "/" ? p_localPath : p_localPath + "/";
  210. }
  211. }
  212. /**
  213. * @private
  214. */
  215. public function get localPath():String
  216. {
  217. return _localPath;
  218. }
  219. [Inspectable (type="String", defaultValue="", name="Collada File") ]
  220. /**
  221. * A relative reference to the external collada file to be used
  222. * @return String
  223. *
  224. */
  225. public function set colladaFile(p_colladaFile:String):void
  226. {
  227. if(_colladaFile != p_colladaFile && p_colladaFile.length > 0)
  228. {
  229. if(debug) log.debug("set colladaFile", p_colladaFile);
  230. rebuildCollada = true;
  231. _colladaFile = p_colladaFile;
  232. }
  233. }
  234. public function get colladaFile():String
  235. {
  236. return _colladaFile;
  237. }
  238. [Collection(name="Materials List", collectionClass="fl.data.SimpleDataProvider", collectionItem="org.papervision3d.core.components.as3.collections.MaterialsListItem", identifier="item")]
  239. /**
  240. * @private
  241. */
  242. public function set extMaterials(p_extMaterials:SimpleDataProvider):void
  243. {
  244. if(p_extMaterials.dataProvider.length > 0 && !checkMaterialListsMatch(extMaterials, p_extMaterials))
  245. {
  246. if(debug) log.debug("****** COMPARE", checkMaterialListsMatch(extMaterials, p_extMaterials));
  247. _extMaterials = p_extMaterials;
  248. rebuildCollada = true;
  249. }
  250. }
  251. /**
  252. * @private
  253. */
  254. public function get extMaterials():SimpleDataProvider { return _extMaterials; }
  255. [Inspectable (type="Number", defaultValue=.01, name="Scale") ]
  256. /**
  257. * @private
  258. */
  259. public function set sceneScale(p_scale:Number):void
  260. {
  261. if(p_scale == _sceneScale) return;
  262. _sceneScale = p_scale;
  263. if(isLivePreview && (collada != null && colladaFile.length > 0))
  264. {
  265. // force an object redraw
  266. rebuildCollada = true;
  267. }
  268. }
  269. /**
  270. * @private
  271. */
  272. public function get sceneScale():Number
  273. {
  274. return _sceneScale;
  275. }
  276. [Inspectable (type="Object", defaultValue="pitch:0, yaw:0, roll:0", name="Initial Rotation") ]
  277. /**
  278. * @private
  279. */
  280. public function set rotationList(p_rotation:Object):void
  281. {
  282. _rotationList = p_rotation;
  283. }
  284. /**
  285. * @private
  286. */
  287. public function get rotationList():Object
  288. {
  289. return _rotationList;
  290. }
  291. public function PV3DColladaScene()
  292. {
  293. //BitmapMaterial.AUTO_MIP_MAPPING = true;
  294. super();
  295. }
  296. /**
  297. * @private
  298. */
  299. override protected function init3D():void
  300. {
  301. StageTools.stage = stage;
  302. super.init3D();
  303. initScene();
  304. }
  305. /**
  306. * @private
  307. */
  308. protected function initScene():void
  309. {
  310. }
  311. /**
  312. * @private
  313. * Creates the 3 main types of materials and loads external materials.
  314. *
  315. * Note that smooth has been pulled. It was causing rte's about smooth not being a property of the materials. Will have to fix later.
  316. */
  317. protected function createMaterials():void
  318. {
  319. if(debug) log.debug("extMaterials", extMaterials.dataProvider ? extMaterials.dataProvider.length : 0);
  320. var loadCollada:Boolean = false;
  321. if(extMaterials.dataProvider.length > 0)
  322. {
  323. // reset the materials que
  324. materialsQue = new Dictionary();
  325. var clrMat:ColorMaterial = new ColorMaterial(0x00ff00, .75);
  326. for(var i:Number=0;i<extMaterials.dataProvider.length;i++)
  327. {
  328. // materials are in library with linkage
  329. var materialsListItem:MaterialsListItem = MaterialsListItem(extMaterials.dataProvider[i]);
  330. var mov:MovieMaterial;
  331. switch(materialsListItem.materialType.toLowerCase())
  332. {
  333. case "bitmapassetmaterial":
  334. if(isLivePreview)
  335. {
  336. materialsList.addMaterial(clrMat, materialsListItem.materialName);
  337. }else
  338. {
  339. var bam:BitmapAssetMaterial = new BitmapAssetMaterial(materialsListItem.materialLocation);
  340. bam.precise = materialsListItem.precisionMaterial;
  341. loadCollada = true;
  342. bam.oneSide = materialsListItem.singleSided;
  343. if( materialsListItem.interactive ) bam.interactive = materialsListItem.interactive;
  344. if( materialsListItem.smooth ) bam.smooth = materialsListItem.smooth;
  345. if(materialsListItem.precisionMaterial)
  346. {
  347. //var pbam:PreciseBitmapAssetMaterial = PreciseBitmapAssetMaterial(bam);
  348. bam.precision = materialsListItem.precision;
  349. bam.minimumRenderSize = materialsListItem.minimumRenderSize;
  350. }
  351. materialsList.addMaterial(bam, materialsListItem.materialName);
  352. }
  353. if(!checkForFileLoads(extMaterials)) loadCollada = true;
  354. break;
  355. case "bitmapfilematerial":
  356. var fileLocation:String = isLivePreview ? _localPath + materialsListItem.materialLocation : materialsListItem.materialLocation;
  357. fileLocation = fileLocation.split("\\").join("/");
  358. if(debug) log.debug("File to load", fileLocation);
  359. var bm:BitmapFileMaterial = new BitmapFileMaterial("");
  360. bm.precise = materialsListItem.precisionMaterial;
  361. bm.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleBitmapFileLoadComplete);
  362. materialsQue[bm] = false;
  363. // setting the texture property actually causes the load of the file
  364. bm.texture = fileLocation;
  365. if( materialsListItem.interactive ) bm.interactive = materialsListItem.interactive;
  366. if( materialsListItem.smooth ) bm.smooth = materialsListItem.smooth;
  367. // because we didn't set the URL through the constructor, we have to set it manually if we want it back in the event thats disatched
  368. bm.url = fileLocation;
  369. bm.oneSide = materialsListItem.singleSided;
  370. if(materialsListItem.precisionMaterial)
  371. {
  372. //var pbm:PreciseBitmapFileMaterial = PreciseBitmapFileMaterial(bm);
  373. bm.precision = materialsListItem.precision;
  374. bm.minimumRenderSize = materialsListItem.minimumRenderSize;
  375. }
  376. materialsList.addMaterial(bm, materialsListItem.materialName);
  377. break;
  378. case "movieassetmaterial":
  379. if(isLivePreview)
  380. {
  381. materialsList.addMaterial(clrMat, materialsListItem.materialName);
  382. }else
  383. {
  384. mov = new MovieAssetMaterial(materialsListItem.materialLocation, materialsListItem.transparent);
  385. mov.precise = materialsListItem.precisionMaterial;
  386. if(materialsListItem.animated) mov.animated = true;
  387. mov.oneSide = materialsListItem.singleSided;
  388. if( materialsListItem.interactive ) mov.interactive = materialsListItem.interactive;
  389. if( materialsListItem.smooth ) mov.smooth = materialsListItem.smooth;
  390. if(materialsListItem.precisionMaterial)
  391. {
  392. //var pmov:PreciseMovieAssetMaterial = PreciseMovieAssetMaterial(mov);
  393. mov.precision = materialsListItem.precision;
  394. mov.minimumRenderSize = materialsListItem.minimumRenderSize;
  395. }
  396. materialsList.addMaterial(mov, materialsListItem.materialName);
  397. }
  398. if(!checkForFileLoads(extMaterials)) loadCollada = true;
  399. break;
  400. case "moviematerial":
  401. if(isLivePreview)
  402. {
  403. materialsList.addMaterial(clrMat, materialsListItem.materialName);
  404. }else
  405. {
  406. var movieClipReference:Sprite = StageTools.buildObjectFromString(materialsListItem.materialLocation) as Sprite;
  407. if( !movieClipReference )
  408. {
  409. trace("please privide a valid MovieClip or sprite instance");
  410. log.error("please privide a valid MovieClip or sprite instance");
  411. break;
  412. }
  413. mov = new MovieMaterial(movieClipReference, materialsListItem.transparent);
  414. mov.precise = materialsListItem.precisionMaterial;
  415. if(materialsListItem.animated) mov.animated = true;
  416. mov.oneSide = materialsListItem.singleSided;
  417. if( materialsListItem.interactive ) mov.interactive = materialsListItem.interactive;
  418. if( materialsListItem.smooth ) mov.smooth = materialsListItem.smooth;
  419. if(materialsListItem.precisionMaterial)
  420. {
  421. //var pmm:PreciseMovieMaterial = PreciseMovieMaterial(mov);
  422. mov.precision = materialsListItem.precision;
  423. mov.minimumRenderSize = materialsListItem.minimumRenderSize;
  424. }
  425. materialsList.addMaterial(mov, materialsListItem.materialName);
  426. }
  427. if(!checkForFileLoads(extMaterials)) loadCollada = true;
  428. break;
  429. }
  430. }
  431. }else
  432. {
  433. if(debug) log.debug("*************************** NO MATERIALS TO LOAD***************");
  434. loadCollada = true;
  435. }
  436. if(loadCollada) createColladaScene();
  437. }
  438. /**
  439. * @private
  440. * Checks the load que to make sure all files are loaded before loading the collada scene
  441. */
  442. private function checkForFileLoads(obj:SimpleDataProvider):Boolean
  443. {
  444. for(var i:Number=0;i<obj.dataProvider.length;i++)
  445. {
  446. var materialsListItem:MaterialsListItem = MaterialsListItem(extMaterials.dataProvider[i]);
  447. if(debug){
  448. log.debug("@@@@@@@@@@@@@@@@ checkForFileLoads", materialsListItem.materialType.toLowerCase());
  449. }
  450. if(materialsListItem.materialType.toLowerCase() == "file") return true;
  451. }
  452. return false;
  453. }
  454. /**
  455. * @private
  456. * When an external file is completely loaded, we receive this event and check to see if all the files have been loaded before loading the collada scene
  457. */
  458. protected function handleBitmapFileLoadComplete(e:FileLoadEvent):void
  459. {
  460. if(debug) log.debug("%%%%%% handleBitmapFileLoadComplete", e.file);
  461. materialsQue[e.target] = true;
  462. var bm:BitmapFileMaterial = BitmapFileMaterial(e.target);
  463. bm.removeEventListener(FileLoadEvent.LOAD_COMPLETE, handleBitmapFileLoadComplete);
  464. if(collada != null && materialsList.numMaterials > 0) collada.materials = materialsList;
  465. if(colladaFile.length > 0 && checkLoadedQue())
  466. {
  467. if(debug) log.debug("should load collada after getting all bitmaps");
  468. createColladaScene();
  469. }
  470. }
  471. /**
  472. * @private
  473. */
  474. protected function checkLoadedQue():Boolean
  475. {
  476. for each(var items:Object in materialsQue)
  477. {
  478. if(!items) return false;
  479. }
  480. return true;
  481. }
  482. /**
  483. * @private
  484. */
  485. override protected function stageResizeHandler(e:Event):void
  486. {
  487. if(!resizeWithStage) return;
  488. if(debug) log.debug("stageResize");
  489. resizeStage();
  490. }
  491. /**
  492. * @private
  493. * Creates the Collada object and loads the file
  494. */
  495. protected function createColladaScene():void
  496. {
  497. if(colladaFile.length == 0) return;
  498. if(debug) log.debug("createColladaScene", colladaFile, scene == null);
  499. if(collada != null) scene.removeChild(collada);
  500. fileLocation = isLivePreview ? _localPath + colladaFile : colladaFile;
  501. if(debug) log.debug("fileLocation for collada", fileLocation);
  502. collada = scene.addChild( new DAE() ) as DAE;
  503. collada.addEventListener( Event.COMPLETE, handleLoadComplete );
  504. collada.addEventListener( ProgressEvent.PROGRESS, handleLoadProgress );
  505. collada.addEventListener( IOErrorEvent.IO_ERROR, handleLoadError);
  506. collada.scale = sceneScale;
  507. /*
  508. if( collada && collada.container ) collada.container.graphics.clear();
  509. collada = new Collada(fileLocation, materialsList, sceneScale,{localPath:localPath});
  510. scene.addChild(collada);
  511. collada.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleLoadComplete);
  512. collada.addEventListener(FileLoadEvent.LOAD_PROGRESS, handleLoadProgress);
  513. collada.addEventListener(FileLoadEvent.LOAD_ERROR, handleLoadError);
  514. collada.addEventListener(FileLoadEvent.SECURITY_LOAD_ERROR, handleLoadError);
  515. */
  516. }
  517. /**
  518. * @private
  519. * Called when Collada file is completely rendered
  520. */
  521. protected function handleLoadComplete(e:Event):void
  522. {
  523. if(debug) log.debug("handleLoadComplete - Collada");
  524. // remove listeners
  525. collada.removeEventListener( Event.COMPLETE, handleLoadComplete );
  526. collada.removeEventListener( ProgressEvent.PROGRESS, handleLoadProgress );
  527. collada.removeEventListener( IOErrorEvent.IO_ERROR, handleLoadError);
  528. finalizeColladaLoad();
  529. }
  530. /**
  531. * @private
  532. * Called when Collada progress event is dispatched
  533. */
  534. protected function handleLoadProgress(e:ProgressEvent):void
  535. {
  536. dispatchEvent(new FileLoadEvent(SCENE_LOAD_PROGRESS, fileLocation, e.bytesLoaded, e.bytesTotal));
  537. }
  538. /**
  539. * @private
  540. * Called when Collada has an error with loading the DAE file specified
  541. */
  542. protected function handleLoadError(e:IOErrorEvent):void
  543. {
  544. dispatchEvent(new FileLoadEvent(SCENE_LOAD_ERROR, fileLocation, 0, 0, e.text));
  545. }
  546. /**
  547. * @private
  548. * Called after Collada file is loaded completely. sets the rotation, and updates the scene.
  549. */
  550. protected function finalizeColladaLoad():void
  551. {
  552. collada.rotationX = rotationList.pitch;
  553. collada.rotationY = rotationList.yaw;
  554. collada.rotationZ = rotationList.roll;
  555. updateScene();
  556. dispatchEvent(new FileLoadEvent(SCENE_COMPLETE));
  557. // set to false so no unnecessary redraws occur
  558. rebuildCollada = false;
  559. if(sceneRotation && !isLivePreview)
  560. {
  561. ObjectController.getInstance().registerStage(this.stage);
  562. ObjectController.getInstance().registerControlObject(collada);
  563. }
  564. // for debugging
  565. if(debug) showChildren();
  566. }
  567. /**
  568. * @private
  569. * Just for testing to see the children of the collada object
  570. */
  571. private function showChildren():void
  572. {
  573. //for each(var item:Object in collada.children) if(debug) trace("collada children: ", item.name);
  574. }
  575. /**
  576. * @private
  577. */
  578. override protected function handleTimerUpdate(e:TimerEvent):void
  579. {
  580. updateScene();
  581. }
  582. /**
  583. * @private
  584. * Used for matching the materials list that comes in when an update occurs on the component at Designtime. A brand new version is sent with every change to the
  585. * component at design time, so we have to crawl through and verify if it's been changed to really know if we need to re-render the collada scene.
  586. */
  587. private function checkMaterialListsMatch(obj_0:SimpleDataProvider, obj_1:SimpleDataProvider):Boolean
  588. {
  589. if(obj_0.dataProvider.length != obj_1.dataProvider.length) return false;
  590. for(var i:Number=0;i<obj_0.dataProvider.length;i++)
  591. {
  592. // materials are in library with linkage
  593. var m0:MaterialsListItem = MaterialsListItem(obj_0.dataProvider[i]);
  594. var m1:MaterialsListItem = MaterialsListItem(obj_1.dataProvider[i]);
  595. var props:Array = PropertyTools.getProperties(m0);
  596. for (var ii:Number=0;i<props.length;i++)
  597. {
  598. if(debug) log.debug("compare", m0[props[i].name] + ", " + m1[props[i].name]);
  599. if(m0[props[i].name] != m1[props[i].name]) return false;
  600. }
  601. }
  602. return true;
  603. }
  604. }
  605. }