two.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098
  1. /*
  2. The MIT License (MIT)
  3. Copyright (c) 2014-2020 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  4. */
  5. // VWF & TWO JS model driver
  6. import { Fabric } from '/core/vwf/fabric.js';
  7. class TwoModel extends Fabric {
  8. constructor(module) {
  9. console.log("TwoModel constructor");
  10. super(module, "Model");
  11. }
  12. factory() {
  13. let _self_ = this;
  14. return this.load(this.module,
  15. {
  16. // == Module Definition ====================================================================
  17. // -- pipeline -----------------------------------------------------------------------------
  18. // pipeline: [ log ], // vwf <=> log <=> scene
  19. // -- initialize ---------------------------------------------------------------------------
  20. initialize: function () {
  21. var self = this;
  22. this.state = {
  23. nodes: {},
  24. scenes: {},
  25. prototypes: {},
  26. createLocalNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  27. childSource, childType, childIndex, childName, callback) {
  28. return {
  29. "parentID": nodeID,
  30. "ID": childID,
  31. "extendsID": childExtendsID,
  32. "implementsIDs": childImplementsIDs,
  33. "source": childSource,
  34. "type": childType,
  35. "name": childName,
  36. "prototypes": undefined
  37. };
  38. },
  39. isNodeComponent: function (prototypes) {
  40. var found = false;
  41. if (prototypes) {
  42. for (var i = 0; i < prototypes.length && !found; i++) {
  43. found = (prototypes[i] === "proxy/two/node.vwf");
  44. }
  45. }
  46. return found;
  47. },
  48. isClass: function (prototypes, classID) {
  49. if (prototypes) {
  50. for (var i = 0; i < prototypes.length; i++) {
  51. if (prototypes[i] === classID) {
  52. //console.info( "prototypes[ i ]: " + prototypes[ i ] );
  53. return true;
  54. }
  55. }
  56. }
  57. return false;
  58. },
  59. isTwoTextureDefinition: function (prototypes) {
  60. var found = false;
  61. if (prototypes) {
  62. for (var i = 0; i < prototypes.length && !found; i++) {
  63. found = (prototypes[i] == "proxy/two/texture.vwf");
  64. }
  65. }
  66. return found;
  67. },
  68. isTwoRectangleDefinition: function (prototypes) {
  69. var found = false;
  70. if (prototypes) {
  71. for (var i = 0; i < prototypes.length && !found; i++) {
  72. found = (prototypes[i] == "proxy/two/rectangle.vwf");
  73. }
  74. }
  75. return found;
  76. },
  77. isTwoCurveDefinition: function (prototypes) {
  78. var found = false;
  79. if (prototypes) {
  80. for (var i = 0; i < prototypes.length && !found; i++) {
  81. found = (prototypes[i] == "proxy/two/curve.vwf");
  82. }
  83. }
  84. return found;
  85. },
  86. isTwoEllipseDefinition: function (prototypes) {
  87. var found = false;
  88. if (prototypes) {
  89. for (var i = 0; i < prototypes.length && !found; i++) {
  90. found = (prototypes[i] == "proxy/two/ellipse.vwf");
  91. }
  92. }
  93. return found;
  94. },
  95. isTwoAnchorDefinition: function (prototypes) {
  96. var found = false;
  97. if (prototypes) {
  98. for (var i = 0; i < prototypes.length && !found; i++) {
  99. found = (prototypes[i] == "proxy/two/anchor.vwf");
  100. }
  101. }
  102. return found;
  103. },
  104. isTwoGroupDefinition: function (prototypes) {
  105. var found = false;
  106. if (prototypes) {
  107. for (var i = 0; i < prototypes.length && !found; i++) {
  108. found = (prototypes[i] == "proxy/two/group.vwf");
  109. }
  110. }
  111. return found;
  112. },
  113. isTwoPathDefinition: function (prototypes) {
  114. var found = false;
  115. if (prototypes) {
  116. for (var i = 0; i < prototypes.length && !found; i++) {
  117. found = (prototypes[i] == "proxy/two/path.vwf");
  118. }
  119. }
  120. return found;
  121. },
  122. isTwoTextDefinition: function (prototypes) {
  123. var found = false;
  124. if (prototypes) {
  125. for (var i = 0; i < prototypes.length && !found; i++) {
  126. found = (prototypes[i] == "proxy/two/text.vwf");
  127. }
  128. }
  129. return found;
  130. },
  131. setFromValue: function (propertyValue) {
  132. var value = []; //goog.vec.Vec3.create();
  133. if (Array.isArray(propertyValue) || propertyValue instanceof Float32Array) {
  134. value = propertyValue;
  135. } else if (typeof propertyValue === 'string') {
  136. if (propertyValue.includes(',')) {
  137. value = propertyValue.split(',').map(el => { return parseFloat(el) })
  138. }
  139. }
  140. return value
  141. },
  142. createObject: function (node, config) {
  143. var protos = node.prototypes;
  144. var obj = undefined;
  145. if (this.isClass(protos, "proxy/two/scene.vwf")) {
  146. // Make an instance of two and place it on the page.
  147. // let el = document.createElement("space");
  148. // document.querySelector("body").appendChild(el);
  149. // let params = { width: 800, height: 600 };
  150. // obj = new Two(params).appendTo(el);
  151. obj = new Two({
  152. type: Two.Types.webgl, //webgl
  153. fullscreen: true,
  154. autostart: true
  155. }).appendTo(document.body);
  156. obj.renderer.domElement.style.position = 'absolute';
  157. obj.renderer.domElement.style.top = 0;
  158. obj.renderer.domElement.style.left = 0;
  159. obj.nodeName = "space";
  160. obj.nodeID = node.ID;
  161. this.scenes[node.ID] = node;
  162. }
  163. if (this.isTwoRectangleDefinition(protos)) {
  164. obj = new Two.Rectangle(0, 0, 10, 10);
  165. obj.nodeName = "rectangle";
  166. obj.nodeID = node.ID;
  167. }
  168. if (this.isTwoTextDefinition(protos)) {
  169. obj = new Two.Text();
  170. obj.nodeName = "text";
  171. obj.nodeID = node.ID;
  172. }
  173. if (this.isTwoAnchorDefinition(protos)) {
  174. obj = new Two.Anchor();
  175. obj.nodeName = "anchor";
  176. obj.nodeID = node.ID;
  177. }
  178. if (this.isTwoEllipseDefinition(protos)) {
  179. obj = new Two.Ellipse(0, 0, 10);
  180. obj.nodeName = "ellipse";
  181. obj.nodeID = node.ID;
  182. }
  183. if (this.isTwoGroupDefinition(protos)) {
  184. obj = new Two.Group();
  185. obj.nodeName = "group";
  186. obj.nodeID = node.ID;
  187. }
  188. if (this.isTwoCurveDefinition(protos)) {
  189. obj = new Two.Path();
  190. obj.nodeName = "path";
  191. obj.nodeID = node.ID;
  192. }
  193. if (this.isTwoTextureDefinition(protos)) {
  194. obj = new Two.Texture();
  195. obj.nodeName = "texture";
  196. obj.nodeID = node.ID;
  197. }
  198. return obj
  199. },
  200. addNodeToHierarchy: function (node) {
  201. if (node.obj) {
  202. if (this.nodes[node.parentID] !== undefined) {
  203. var parent = this.nodes[node.parentID];
  204. if (parent.obj) {
  205. if (parent.children === undefined) {
  206. parent.children = [];
  207. }
  208. parent.children.push(node.ID);
  209. //console.info( "Adding child: " + childID + " to " + nodeID );
  210. if (node.obj.nodeName !== "texture" && node.obj.nodeName !== "anchor") {
  211. parent.obj.add(node.obj);
  212. }
  213. }
  214. }
  215. if (node.obj.nodeName !== "space") {
  216. node.scene = this.scenes[self.kernel.application()];
  217. // if(node.parentID == self.kernel.application()){
  218. // node.scene.obj.add(node.obj);
  219. // }
  220. }
  221. }
  222. }
  223. };
  224. this.state.kernel = this.kernel.kernel.kernel;
  225. //this.Tone = Tone;
  226. //this.state.kernel = this.kernel.kernel.kernel;
  227. },
  228. // == Model API ============================================================================
  229. // -- creatingNode -------------------------------------------------------------------------
  230. creatingNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  231. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  232. // If the parent nodeID is 0, this node is attached directly to the root and is therefore either
  233. // the scene or a prototype. In either of those cases, save the uri of the new node
  234. var childURI = (nodeID === 0 ? childIndex : undefined);
  235. var appID = this.kernel.application();
  236. // If the node being created is a prototype, construct it and add it to the array of prototypes,
  237. // and then return
  238. var prototypeID = _self_.utility.ifPrototypeGetId(appID, this.state.prototypes, nodeID, childID);
  239. if (prototypeID !== undefined) {
  240. this.state.prototypes[prototypeID] = {
  241. parentID: nodeID,
  242. ID: childID,
  243. extendsID: childExtendsID,
  244. implementsID: childImplementsIDs,
  245. source: childSource,
  246. type: childType,
  247. name: childName
  248. };
  249. return;
  250. }
  251. var protos = _self_.getPrototypes(this.kernel, childExtendsID);
  252. //var kernel = this.kernel.kernel.kernel;
  253. var node;
  254. if (this.state.isNodeComponent(protos)) {
  255. // Create the local copy of the node properties
  256. if (this.state.nodes[childID] === undefined) {
  257. this.state.nodes[childID] = this.state.createLocalNode(nodeID, childID, childExtendsID, childImplementsIDs,
  258. childSource, childType, childIndex, childName, callback);
  259. }
  260. node = this.state.nodes[childID];
  261. node.prototypes = protos;
  262. node.obj = this.state.createObject(node);
  263. this.state.addNodeToHierarchy(node);
  264. //let aframeDriver = vwf.views["/drivers/view/aframe"];
  265. //notifyDriverOfPrototypeAndBehaviorProps();
  266. }
  267. },
  268. // -- initializingNode -------------------------------------------------------------------------
  269. // initializingNode: function( nodeID, childID, childExtendsID, childImplementsIDs,
  270. // childSource, childType, childIndex, childName ) {
  271. // },
  272. // -- deletingNode -------------------------------------------------------------------------
  273. deletingNode: function (nodeID) {
  274. if (nodeID) {
  275. var childNode = this.state.nodes[nodeID];
  276. if (!childNode) return;
  277. if (childNode !== undefined) {
  278. if (childNode.children) {
  279. for (var i = 0; i < childNode.children.length; i++) {
  280. this.deletingNode(childNode.children[i]);
  281. }
  282. }
  283. if (childNode.obj !== undefined) {
  284. // removes and destroys object
  285. //let space = childNode.scene.obj;
  286. childNode.obj.parent.remove(childNode.obj);
  287. childNode.obj = undefined;
  288. }
  289. delete this.state.nodes[nodeID];
  290. }
  291. }
  292. },
  293. // -- initializingProperty -----------------------------------------------------------------
  294. initializingProperty: function (nodeID, propertyName, propertyValue) {
  295. var value = undefined;
  296. var node = this.state.nodes[nodeID];
  297. if (node !== undefined) {
  298. value = this.settingProperty(nodeID, propertyName, propertyValue);
  299. }
  300. return value;
  301. },
  302. //callingMethod
  303. callingMethod: function (nodeID, methodName, methodParameters) {
  304. let self = this;
  305. var node = this.state.nodes[nodeID];
  306. if (!node) return;
  307. if (node && node.obj) {
  308. if (methodName == "getJointsAtTime") {
  309. let time = methodParameters[0];
  310. return node.motionData[time];
  311. }
  312. if (methodName == "getJointAtTime") {
  313. let time = methodParameters[0];
  314. let jointID = methodParameters[1];
  315. return node.motionData[time][jointID];
  316. }
  317. }
  318. },
  319. // -- creatingProperty ---------------------------------------------------------------------
  320. creatingProperty: function (nodeID, propertyName, propertyValue) {
  321. return this.initializingProperty(nodeID, propertyName, propertyValue);
  322. },
  323. // -- settingProperty ----------------------------------------------------------------------
  324. settingProperty: function (nodeID, propertyName, propertyValue) {
  325. let self = this;
  326. let node = this.state.nodes[nodeID];
  327. var value = undefined;
  328. if (node && node.obj && _self_.utility.validObject(propertyValue)) {
  329. let object = node.obj;
  330. if (value === undefined && self.state.isTwoGroupDefinition(node.prototypes)) {
  331. value = propertyValue;
  332. switch (propertyName) {
  333. case "x":
  334. object.translation.x = propertyValue
  335. break;
  336. case "y":
  337. object.translation.y = propertyValue
  338. break;
  339. case "translation":
  340. let translation = this.state.setFromValue(propertyValue);
  341. object.translation.set(translation[0], translation[1])
  342. break;
  343. case "rotation":
  344. object.rotation = propertyValue
  345. break;
  346. case "scale":
  347. object.scale = propertyValue
  348. break;
  349. case "opacity":
  350. object.opacity = propertyValue
  351. break;
  352. // case "mask":
  353. // object.mask = propertyValue
  354. // break;
  355. case "visible":
  356. object.visible = propertyValue
  357. break;
  358. default:
  359. value = undefined;
  360. break;
  361. }
  362. }
  363. if (value === undefined && self.state.isTwoTextDefinition(node.prototypes)) {
  364. value = propertyValue;
  365. switch (propertyName) {
  366. case "translation":
  367. let translation = this.state.setFromValue(propertyValue);
  368. object.translation.set(translation[0], translation[1])
  369. break;
  370. case "rotation":
  371. object.rotation = propertyValue
  372. break;
  373. case "scale":
  374. object.scale = propertyValue
  375. break;
  376. case "fill":
  377. object.fill = propertyValue
  378. break;
  379. case "stroke":
  380. object.stroke = propertyValue
  381. break;
  382. case "linewidth":
  383. object.linewidth = propertyValue
  384. break;
  385. case "opacity":
  386. object.opacity = propertyValue
  387. break;
  388. case "text":
  389. object.value = propertyValue
  390. break;
  391. case "family":
  392. object.family = propertyValue
  393. break;
  394. case "size":
  395. object.size = propertyValue
  396. break;
  397. case "style":
  398. object.style = propertyValue
  399. break;
  400. case "weight":
  401. object.weight = propertyValue
  402. break;
  403. case "visible":
  404. object.visible = propertyValue
  405. break;
  406. // "text": null,
  407. // "family": null,
  408. // "size": null,
  409. // "style": null,
  410. // "weight": null,
  411. // "visible": null,
  412. default:
  413. value = undefined;
  414. break;
  415. }
  416. }
  417. if (value === undefined && self.state.isTwoPathDefinition(node.prototypes)) {
  418. value = propertyValue;
  419. switch (propertyName) {
  420. case "x":
  421. object.translation.x = propertyValue
  422. break;
  423. case "y":
  424. object.translation.y = propertyValue
  425. break;
  426. case "translation":
  427. object.translation.set(propertyValue[0], propertyValue[1])
  428. break;
  429. case "rotation":
  430. object.rotation = propertyValue
  431. break;
  432. case "scale":
  433. object.scale = propertyValue
  434. break;
  435. case "fill":
  436. if (propertyValue.includes('https') || propertyValue.startsWith('/')) {
  437. let name = propertyValue//.split('=')[1];
  438. if (name.includes('webm') || name.includes('mp4')) {
  439. var video = document.createElement('video');
  440. video.src = name;
  441. video.autoplay = false;
  442. video.loop = true;
  443. video.muted = true;
  444. object.fill = new Two.Texture(video);
  445. node.fillType = "video";
  446. } else {
  447. let texture = new Two.Texture(name);
  448. object.fill = texture
  449. node.fillType = "image";
  450. }
  451. } else {
  452. object.fill = propertyValue
  453. node.fillType = "color";
  454. }
  455. break;
  456. case "stroke":
  457. object.stroke = propertyValue
  458. break;
  459. case "linewidth":
  460. object.linewidth = propertyValue
  461. break;
  462. case "opacity":
  463. object.opacity = propertyValue
  464. break;
  465. case "clip":
  466. object.clip = propertyValue
  467. break;
  468. case "curved":
  469. object.curved = propertyValue
  470. break;
  471. case "closed":
  472. object.closed = propertyValue
  473. break;
  474. case "join":
  475. object.join = propertyValue
  476. break;
  477. case "automatic":
  478. object.automatic = propertyValue
  479. break;
  480. case "vertices":
  481. object.vertices = [];
  482. propertyValue.forEach(v => {
  483. let a = new Two.Anchor(v.x, v.y);
  484. object.vertices.push(a);
  485. })
  486. break;
  487. default:
  488. value = undefined;
  489. break;
  490. }
  491. }
  492. if (value === undefined && self.state.isTwoAnchorDefinition(node.prototypes)) {
  493. value = propertyValue;
  494. switch (propertyName) {
  495. case "x":
  496. object.x = propertyValue
  497. break;
  498. case "y":
  499. object.y = propertyValue
  500. break;
  501. case "command":
  502. object.command = propertyValue
  503. break;
  504. default:
  505. value = undefined;
  506. break;
  507. }
  508. }
  509. if (value === undefined && self.state.isTwoRectangleDefinition(node.prototypes)) {
  510. value = propertyValue;
  511. switch (propertyName) {
  512. case "height":
  513. object.height = propertyValue
  514. break;
  515. case "width":
  516. object.width = propertyValue
  517. break;
  518. default:
  519. value = undefined;
  520. break;
  521. }
  522. }
  523. if (value === undefined && self.state.isTwoEllipseDefinition(node.prototypes)) {
  524. value = propertyValue;
  525. switch (propertyName) {
  526. case "height":
  527. object.height = propertyValue
  528. break;
  529. case "width":
  530. object.width = propertyValue
  531. break;
  532. default:
  533. value = undefined;
  534. break;
  535. }
  536. }
  537. if (value === undefined && self.state.isTwoTextureDefinition(node.prototypes)) {
  538. value = propertyValue;
  539. switch (propertyName) {
  540. case "src":
  541. object.src = propertyValue
  542. break;
  543. default:
  544. value = undefined;
  545. break;
  546. }
  547. }
  548. }
  549. return value;
  550. },
  551. // -- gettingProperty ----------------------------------------------------------------------
  552. gettingProperty: function (nodeID, propertyName, propertyValue) {
  553. let self = this;
  554. let node = this.state.nodes[nodeID];
  555. let value = undefined;
  556. if (node && node.obj) {
  557. let object = node.obj;
  558. if (value === undefined && self.state.isTwoGroupDefinition(node.prototypes)) {
  559. switch (propertyName) {
  560. case "x":
  561. value = object.translation.x
  562. break;
  563. case "y":
  564. value = object.translation.y
  565. break;
  566. case "translation":
  567. let translation = [object.translation.x, object.translation.y]
  568. value = translation
  569. break;
  570. case "rotation":
  571. value = object.rotation
  572. break;
  573. case "scale":
  574. value = object.scale
  575. break;
  576. case "opacity":
  577. value = object.opacity
  578. break;
  579. case "twoWidth":
  580. value = node.scene.obj.width
  581. break;
  582. case "twoHeight":
  583. value = node.scene.obj.height
  584. break;
  585. case "visible":
  586. value = object.visible
  587. break;
  588. // case "mask":
  589. // value = object.mask
  590. // break;
  591. }
  592. }
  593. if (value === undefined && self.state.isTwoTextDefinition(node.prototypes)) {
  594. switch (propertyName) {
  595. case "translation":
  596. let translation = [object.translation.x, object.translation.y]
  597. value = translation
  598. break;
  599. case "rotation":
  600. value = object.rotation
  601. break;
  602. case "scale":
  603. value = object.scale
  604. break;
  605. case "fill":
  606. value = object.fill
  607. break;
  608. case "text":
  609. value = object.value
  610. break;
  611. case "family":
  612. value = object.family
  613. break;
  614. case "size":
  615. value = object.size
  616. break;
  617. case "stroke":
  618. value = object.stroke
  619. break;
  620. case "linewidth":
  621. value = object.linewidth
  622. break;
  623. case "opacity":
  624. value = object.opacity
  625. break;
  626. case "style":
  627. value = object.style
  628. break;
  629. case "weight":
  630. value = object.weight
  631. break;
  632. case "visible":
  633. value = object.visible
  634. break;
  635. }
  636. }
  637. if (value === undefined && self.state.isTwoPathDefinition(node.prototypes)) {
  638. switch (propertyName) {
  639. case "x":
  640. value = object.translation.x
  641. break;
  642. case "y":
  643. value = object.translation.y
  644. break;
  645. case "translation":
  646. let translation = [object.translation.x, object.translation.y]
  647. value = translation
  648. break;
  649. case "rotation":
  650. value = object.rotation
  651. break;
  652. case "scale":
  653. value = object.scale
  654. break;
  655. case "fill":
  656. if (typeof object.fill == 'object' && object.fill.src) {
  657. value = object.fill.src
  658. } else {
  659. value = object.fill
  660. }
  661. break;
  662. case "stroke":
  663. value = object.stroke
  664. break;
  665. case "linewidth":
  666. value = object.linewidth
  667. break;
  668. case "opacity":
  669. value = object.opacity
  670. break;
  671. case "clip":
  672. value = object.clip
  673. break;
  674. case "twoWidth":
  675. value = node.scene.obj.width
  676. break;
  677. case "twoHeight":
  678. value = node.scene.obj.height
  679. break;
  680. case "curved":
  681. value = object.curved
  682. break;
  683. case "automatic":
  684. value = object.automatic
  685. break;
  686. case "closed":
  687. value = object.closed
  688. break;
  689. case "join":
  690. value = object.join
  691. break;
  692. case "vertices":
  693. let anchors = object.vertices;
  694. let vertices = anchors.map(a => {
  695. return { x: a.x, y: a.y }
  696. })
  697. value = vertices
  698. break;
  699. }
  700. }
  701. if (value === undefined && self.state.isTwoAnchorDefinition(node.prototypes)) {
  702. switch (propertyName) {
  703. case "x":
  704. value = object.x
  705. break;
  706. case "y":
  707. value = object.y
  708. break;
  709. case "command":
  710. value = object.command
  711. break;
  712. }
  713. }
  714. if (value === undefined && self.state.isTwoRectangleDefinition(node.prototypes)) {
  715. switch (propertyName) {
  716. case "height":
  717. value = object.height
  718. break;
  719. case "width":
  720. value = object.width
  721. break;
  722. }
  723. }
  724. if (value === undefined && self.state.isTwoEllipseDefinition(node.prototypes)) {
  725. switch (propertyName) {
  726. case "height":
  727. value = object.height
  728. break;
  729. case "width":
  730. value = object.width
  731. break;
  732. }
  733. }
  734. if (value === undefined && self.state.isTwoTextureDefinition(node.prototypes)) {
  735. switch (propertyName) {
  736. case "src":
  737. value = object.src
  738. break;
  739. }
  740. }
  741. }
  742. if (value !== undefined) {
  743. propertyValue = value;
  744. }
  745. return value;
  746. }
  747. });
  748. }
  749. getPrototypes(kernel, extendsID) {
  750. var prototypes = [];
  751. var id = extendsID;
  752. while (id !== undefined) {
  753. prototypes.push(id);
  754. id = kernel.prototype(id);
  755. }
  756. return prototypes;
  757. }
  758. }
  759. export {
  760. TwoModel as default
  761. }