PageRenderTime 2610ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/components/collada/src/com/rockonflash/components/collada/view/PV3DColladaScene.as

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