@antv/g 1.0.0-alpha.29 → 1.0.0-alpha.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,7 +70,6 @@ function () {
70
70
  this.renderingPluginProvider.getContributions({
71
71
  cache: false
72
72
  }).forEach(function (plugin) {
73
- console.log(plugin);
74
73
  plugin.apply(_this);
75
74
  });
76
75
  return [4
@@ -90,6 +89,8 @@ function () {
90
89
  };
91
90
 
92
91
  RenderingService.prototype.render = function () {
92
+ this.sceneGraphService.syncHierarchy(this.renderingContext.root);
93
+
93
94
  if (this.renderingContext.renderReasons.size && this.inited) {
94
95
  this.renderDisplayObject(this.renderingContext.root);
95
96
 
@@ -153,6 +154,7 @@ function () {
153
154
 
154
155
  (0, _tslib.__decorate)([(0, _manaSyringe.contrib)(RenderingPluginContribution), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingPluginProvider", void 0);
155
156
  (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_RenderingContext.RenderingContext), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingContext", void 0);
157
+ (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_SceneGraphService.SceneGraphService), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
156
158
  RenderingService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], RenderingService);
157
159
  return RenderingService;
158
160
  }();
@@ -37,6 +37,7 @@ export interface SceneGraphService {
37
37
  getLocalBounds(element: INode, render?: boolean): AABB | null;
38
38
  getGeometryBounds(element: INode, render?: boolean): AABB | null;
39
39
  getBoundingClientRect(element: INode): Rectangle;
40
+ syncHierarchy(element: INode): void;
40
41
  }
41
42
  /**
42
43
  * update transform in scene graph
@@ -142,5 +143,8 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
142
143
  getLocalBounds(element: INode): AABB | null;
143
144
  getBoundingClientRect(element: INode): Rectangle;
144
145
  private dirtifyWorldInternal;
145
- private updateTransform;
146
+ syncHierarchy(element: INode): void;
147
+ private sync;
148
+ private updateGraphDepth;
149
+ private unfreezeParentToRoot;
146
150
  }
@@ -407,11 +407,16 @@ function () {
407
407
  sortable.dirty = true;
408
408
  }
409
409
 
410
+ this.updateGraphDepth(child);
410
411
  var transform = entity.getComponent(_components.Transform);
411
412
 
412
413
  if (transform) {
413
414
  this.dirtifyWorld(child, transform);
414
415
  }
416
+
417
+ if (transform.frozen) {
418
+ this.unfreezeParentToRoot(child);
419
+ }
415
420
  };
416
421
 
417
422
  DefaultSceneGraphService.prototype.detach = function (child) {
@@ -579,6 +584,10 @@ function () {
579
584
  };
580
585
 
581
586
  DefaultSceneGraphService.prototype.dirtifyWorld = function (element, transform) {
587
+ if (!transform.dirtyFlag) {
588
+ this.unfreezeParentToRoot(element);
589
+ }
590
+
582
591
  this.dirtifyWorldInternal(element, transform);
583
592
  };
584
593
 
@@ -602,10 +611,6 @@ function () {
602
611
  transform = element.entity.getComponent(_components.Transform);
603
612
  }
604
613
 
605
- if (!transform) {
606
- return _glMatrix.mat4.create();
607
- }
608
-
609
614
  if (!transform.localDirtyFlag && !transform.dirtyFlag) {
610
615
  return transform.worldTransform;
611
616
  }
@@ -614,7 +619,7 @@ function () {
614
619
  this.getWorldTransform(element.parentNode);
615
620
  }
616
621
 
617
- this.updateTransform(element, transform);
622
+ this.sync(element, transform);
618
623
  return transform.worldTransform;
619
624
  };
620
625
 
@@ -811,13 +816,14 @@ function () {
811
816
 
812
817
  if (!transform.dirtyFlag) {
813
818
  transform.dirtyFlag = true;
819
+ transform.frozen = false;
814
820
  element.childNodes.forEach(function (child) {
815
821
  var childTransform = child.entity.getComponent(_components.Transform);
816
822
 
817
823
  if (!childTransform.dirtyFlag) {
818
824
  _this.dirtifyWorldInternal(child, childTransform);
819
825
  }
820
- }); // emit on leaf node
826
+ }); // FIXME: emit on leaf node
821
827
 
822
828
  if (element.childNodes.length === 0) {
823
829
  dirtifyRenderable(element);
@@ -825,9 +831,31 @@ function () {
825
831
  }
826
832
  };
827
833
 
828
- DefaultSceneGraphService.prototype.updateTransform = function (element, transform) {
834
+ DefaultSceneGraphService.prototype.syncHierarchy = function (element) {
835
+ var transform = element.entity.getComponent(_components.Transform);
836
+
837
+ if (transform.frozen) {
838
+ return;
839
+ }
840
+
841
+ transform.frozen = true;
842
+
843
+ if (transform.localDirtyFlag || transform.dirtyFlag) {
844
+ this.sync(element, transform);
845
+ }
846
+
847
+ var children = element.childNodes;
848
+
849
+ for (var i = 0; i < children.length; i++) {
850
+ this.syncHierarchy(children[i]);
851
+ }
852
+ };
853
+
854
+ DefaultSceneGraphService.prototype.sync = function (element, transform) {
829
855
  if (transform.localDirtyFlag) {
830
- this.getLocalTransform(element);
856
+ _glMatrix.mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
857
+
858
+ transform.localDirtyFlag = false;
831
859
  }
832
860
 
833
861
  if (transform.dirtyFlag) {
@@ -841,8 +869,36 @@ function () {
841
869
  // @see https://github.com/playcanvas/engine/issues/1077#issuecomment-359765557
842
870
  _glMatrix.mat4.multiply(transform.worldTransform, parentTransform.worldTransform, transform.localTransform);
843
871
  }
872
+ }
873
+ };
874
+
875
+ DefaultSceneGraphService.prototype.updateGraphDepth = function (element) {
876
+ var transform = element.entity.getComponent(_components.Transform);
877
+
878
+ if (element.parentNode) {
879
+ transform.graphDepth = element.parentNode.entity.getComponent(_components.Transform).graphDepth + 1;
880
+ } else {
881
+ transform.graphDepth = 0;
882
+ }
883
+
884
+ var children = element.childNodes;
885
+
886
+ for (var i = 0; i < children.length; i++) {
887
+ this.updateGraphDepth(children[i]);
888
+ }
889
+ };
890
+
891
+ DefaultSceneGraphService.prototype.unfreezeParentToRoot = function (child) {
892
+ var p = child.parentNode;
893
+
894
+ while (p) {
895
+ var transform = p.entity.getComponent(_components.Transform);
896
+
897
+ if (transform) {
898
+ transform.frozen = false;
899
+ }
844
900
 
845
- transform.dirtyFlag = false;
901
+ p = p.parentNode;
846
902
  }
847
903
  };
848
904
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g",
3
- "version": "1.0.0-alpha.29",
3
+ "version": "1.0.0-alpha.33",
4
4
  "description": "A core module including ECS and DI container.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.esm.js",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://github.com/antvis/g#readme",
40
40
  "dependencies": {
41
- "@antv/g-ecs": "^1.0.0-alpha.13",
41
+ "@antv/g-ecs": "^1.0.0-alpha.14",
42
42
  "@antv/g-math": "^1.0.0-alpha.9",
43
43
  "@antv/path-util": "^2.0.14",
44
44
  "@antv/util": "^2.0.13",
@@ -46,11 +46,11 @@
46
46
  "d3-color": "^1.4.0",
47
47
  "eventemitter3": "^4.0.0",
48
48
  "gl-matrix": "^3.1.0",
49
- "mana-syringe": "^0.2.1",
49
+ "mana-syringe": "^0.2.2",
50
50
  "tapable": "2.2.1"
51
51
  },
52
52
  "scripts": {
53
53
  "umd": "webpack"
54
54
  },
55
- "gitHead": "97b0cd921c395a28d0432b33db157723b7967db1"
55
+ "gitHead": "5fd0248267f142dd756e106b908a6793b828454b"
56
56
  }