aframe_old.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. "use strict";
  2. // Copyright 2012 United States Government, as represented by the Secretary of Defense, Under
  3. // Secretary of Defense (Personnel & Readiness).
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed under the License
  11. // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  12. // or implied. See the License for the specific language governing permissions and limitations under
  13. // the License.
  14. /// vwf/view/lesson creates a view interface for instruction text.
  15. ///
  16. /// @module vwf/view/aframe
  17. /// @requires vwf/view
  18. define( [ "module", "vwf/view", "jquery", "jquery-ui" ], function( module, view, $ ) {
  19. let aframeTypes = new Set(["a-camera", "a-entity", "a-box", "a-sphere", "a-sky"]);
  20. return view.load( module, {
  21. // == Module Definition ====================================================================
  22. initialize: function( options ) {
  23. var self = this;
  24. this.nodes = {};
  25. if ( typeof options == "object" ) {
  26. this.rootSelector = options[ "application-root" ];
  27. }
  28. else {
  29. this.rootSelector = options;
  30. }
  31. // Create AFrame example scene
  32. // var $aframediv = $( "<a-scene><a-sphere position='0 1.25 -1' radius='1.25' color='#EF2D5E'></a-sphere> <a-sky color='#ECECEC'></a-sky><a-entity position='0 0 3.8'><a-camera></a-camera></a-entity></a-scene>" );
  33. // $('body').append($aframediv);
  34. },
  35. createdNode: function( nodeID, childID, childExtendsID, childImplementsIDs,
  36. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  37. //the created node is a scene, and has already been added to the state by the model.
  38. //how/when does the model set the state object?
  39. if ( this.state.scenes[ childID ] )
  40. {
  41. document.body.append(this.state.scenes[childID].threeScene);
  42. }
  43. if ( aframeTypes.has(childType)) {
  44. if(this.state.nodes[childID] && this.state.nodes[childID].threeObject instanceof AFRAME.AEntity) {
  45. this.nodes[childID] = {id:childID,extends:childExtendsID};
  46. let scene = this.state.scenes[this.state.nodes[childID].sceneID].threeScene;
  47. if (this.state.nodes[childID].parentID == this.state.nodes[childID].sceneID) {
  48. scene.appendChild(this.state.nodes[childID].threeObject);
  49. } else {
  50. this.state.nodes[nodeID].threeObject.appendChild(this.state.nodes[childID].threeObject);
  51. }
  52. }
  53. }
  54. },
  55. createdProperty: function( nodeId, propertyName, propertyValue ) {
  56. return this.satProperty( nodeId, propertyName, propertyValue );
  57. },
  58. initializedProperty: function (nodeId, propertyName, propertyValue) {
  59. return this.satProperty( nodeId, propertyName, propertyValue );
  60. },
  61. satProperty: function( nodeId, propertyName, propertyValue ) {
  62. },
  63. } );
  64. } );