hilbert-chart-3d 0.4.1 → 0.6.0

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.
@@ -139,16 +139,34 @@ var index = Kapsule({
139
139
  };
140
140
  state.renderObjs.fitToBbox(roBbox, transitionDuration);
141
141
  });
142
+ return this;
142
143
  },
143
144
  zoomToFit: function (state, transitionDuration, padding) {
144
- state.renderObjs.zoomTofit(transitionDuration, padding);
145
+ state.renderObjs.zoomToFit(transitionDuration, padding);
145
146
  return this;
146
147
  },
148
+ getPositionAtVal: (state, ...args) => state.hilbert.getPositionAtVal(...args),
147
149
  _animationCycle(state) {
148
150
  // Frame cycle
149
151
  state.renderObjs.tick();
150
152
  state.animationFrameRequestId = requestAnimationFrame(this._animationCycle);
151
153
  },
154
+ cameraPosition: function (state, ...args) {
155
+ if (args.length) {
156
+ // setter
157
+ state.renderObjs.cameraPosition(...args);
158
+ return this;
159
+ }
160
+ return state.renderObjs.cameraPosition();
161
+ },
162
+ lights: function (state, ...args) {
163
+ if (args.length) {
164
+ // setter
165
+ state.renderObjs.lights(...args);
166
+ return this;
167
+ }
168
+ return state.renderObjs.lights();
169
+ },
152
170
  scene: state => state.renderObjs.scene(),
153
171
  // Expose scene
154
172
  camera: state => state.renderObjs.camera(),
@@ -157,6 +175,29 @@ var index = Kapsule({
157
175
  // Expose renderer
158
176
  controls: state => state.renderObjs.controls(),
159
177
  // Expose controls
178
+ hoverOrderComparator: function (state, dataComp) {
179
+ state.renderObjs.hoverOrderComparator((_a, _b, a, b) => {
180
+ const [da, db] = [a, b].map(i => getHilbertObjData(i?.object, i));
181
+ if (!da) return 1;
182
+ if (!db) return -1;
183
+ return dataComp(da, db);
184
+ });
185
+ return this;
186
+ function getHilbertObjData(obj, intersection) {
187
+ if (!obj) return null;
188
+ const hilbertObj = getHilbertObj(obj);
189
+ const d = hilbertObj?.__data || null;
190
+ return intersection && hilbertObj.isInstancedMesh ? d?.[intersection.instanceId] : d;
191
+ function getHilbertObj(object) {
192
+ let obj = object;
193
+ // recurse up object chain until finding the hilbert object
194
+ while (obj && !obj.hasOwnProperty('__data')) {
195
+ obj = obj.parent;
196
+ }
197
+ return obj;
198
+ }
199
+ }
200
+ },
160
201
  _destructor: function (state) {
161
202
  cancelAnimationFrame(state.animationFrameRequestId);
162
203
  this.data([]);
@@ -187,14 +228,12 @@ var index = Kapsule({
187
228
  el.appendChild(roDomNode);
188
229
  const getHilbertObjData = (obj, intersection) => {
189
230
  if (!obj) return null;
190
- if (intersection && obj.isInstancedMesh) {
191
- return obj.userData.data?.[intersection.instanceId] || null;
192
- }
193
231
  const hilbertObj = getHilbertObj(obj);
194
- return hilbertObj?.__data || null;
232
+ const d = hilbertObj?.__data || null;
233
+ return intersection && hilbertObj.isInstancedMesh ? d?.[intersection.instanceId] : d;
195
234
  function getHilbertObj(object) {
196
235
  let obj = object;
197
- // recurse up object chain until finding the globe object
236
+ // recurse up object chain until finding the hilbert object
198
237
  while (obj && !obj.hasOwnProperty('__data')) {
199
238
  obj = obj.parent;
200
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hilbert-chart-3d",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "A 3d hilbert space-filling curve D3 chart for representing one-dimensional lengths on a three-dimensional space.",
5
5
  "type": "module",
6
6
  "jsdelivr": "dist/hilbert-chart-3d.min.js",
@@ -45,8 +45,8 @@
45
45
  "accessor-fn": "1",
46
46
  "kapsule": "^1.16",
47
47
  "three": ">=0.179 <1",
48
- "three-hilbert": "*",
49
- "three-render-objects": "^1.44"
48
+ "three-hilbert": "1",
49
+ "three-render-objects": "^1.45"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@babel/core": "^8.1.0",