Skip to content

Commit 292ac0e

Browse files
Chiu PeterChiu Peter
authored andcommitted
remove animate from test case for CrystalToolkitAnimation (static)
1 parent 0ae23cc commit 292ac0e

File tree

8 files changed

+282
-10
lines changed

8 files changed

+282
-10
lines changed

demo/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ReactDOM.render(
2727
<section>
2828
<Switch>
2929
<Route path="/">
30-
<CrystalStructureViewer />
30+
<CrystalStructureAnimationViewer />
3131
</Route>
3232
</Switch>
3333
</section>

src/components/crystal-toolkit/CrystalToolkitAnimationScene/CrystalToolkitAnimationScene.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import { MOUNT_NODE_CLASS, Renderer } from '../scene/constants';
66
import Scene from '../scene/Scene';
77

88
const spy = jest.spyOn(Scene.prototype, 'renderScene');
9-
const RENDERSCENE_CALLS_BY_REACT_RENDERING = 3;
10-
// goal is to reach 1 and stay there :)
11-
// MHC: not share why reach 1 is the goal...
12-
// But in this test, when mount, run animate(), addToScene(), and resizeRendererToDisplaySize()
9+
const RENDERSCENE_CALLS_BY_REACT_RENDERING = 3; // goal is to reach 1 and stay there :)
1310

1411
// When we run test, three.js is bundled differently, and we encounter again the bug
1512
// where we have 2 different instances of three

src/components/crystal-toolkit/CrystalToolkitAnimationScene/CrystalToolkitAnimationScene.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ export const CrystalToolkitAnimationScene: React.FC<CrystalToolkitAnimationScene
419419
},
420420
mountNodeDebugRef.current!
421421
));
422-
423422
_s.removeListener();
424423
_s.animate();
424+
425425
/**
426426
* I believe this can be removed because image requesting is now handled by
427427
* the image dropdown.

src/components/crystal-toolkit/scene/Scene.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ export default class Scene {
459459
this.threeUUIDTojsonObject[object.uuid] = childObject;
460460
this.computeIdToThree[`${currentId}--${idx}`] = object;
461461
childObject.id = `${currentId}--${idx}`;
462+
if (childObject.animate) {
463+
objectToAnimate.add(`${currentId}--${idx}`);
464+
}
462465
} else {
463466
const threeObject = new THREE.Object3D();
464467
threeObject.name = childObject.name!;

src/components/crystal-toolkit/scene/animation-helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class AnimationHelper {
6161
} else {
6262
console.warn(`Unknown animationType: ${animationType}`);
6363
}
64-
6564
const positionKF = new THREE.VectorKeyframeTrack('.position', [...kf], values);
6665

6766
let kflVal;

src/components/crystal-toolkit/scene/simple-scene.ts

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,278 @@ export const s4 = {
220220
};
221221

222222
export const s2 = {
223+
name: '_ct_StructureMoleculeComponent_1',
224+
contents: [
225+
{
226+
name: 'atoms',
227+
clickable: true,
228+
contents: [
229+
{
230+
positions: [
231+
[4.2, 4.2, 0],
232+
[0, 4.2, 4.2],
233+
[0, 4.2, 0],
234+
[4.2, 0, 4.2],
235+
[4.2, 4.2, 4.2],
236+
[0, 0, 0],
237+
[0, 0, 4.2],
238+
[4.2, 0, 0]
239+
],
240+
color: '#f9dc3c',
241+
radius: 0.5,
242+
tooltip: 'label',
243+
type: 'spheres',
244+
clickable: true,
245+
keyframes: [0, 1]
246+
},
247+
{
248+
positions: [[2.1, 2.1, 2.1]],
249+
color: '#4444ff',
250+
radius: 0.5,
251+
type: 'spheres',
252+
tooltip: 'label',
253+
clickable: true,
254+
keyframes: [0, 1]
255+
}
256+
],
257+
origin: [-2.1, -2.1, -2.1],
258+
visible: true
259+
},
260+
{
261+
name: 'bonds',
262+
contents: [
263+
{
264+
positionPairs: [
265+
[
266+
[4.2, 4.2, 0],
267+
[3.1500000000000004, 3.1500000000000004, 1.05]
268+
],
269+
[
270+
[0, 4.2, 4.2],
271+
[1.05, 3.1500000000000004, 3.1500000000000004]
272+
],
273+
[
274+
[0, 4.2, 0],
275+
[1.05, 3.1500000000000004, 1.05]
276+
],
277+
[
278+
[4.2, 0, 4.2],
279+
[3.1500000000000004, 1.05, 3.1500000000000004]
280+
],
281+
[
282+
[4.2, 4.2, 4.2],
283+
[3.1500000000000004, 3.1500000000000004, 3.1500000000000004]
284+
],
285+
[
286+
[0, 0, 0],
287+
[1.05, 1.05, 1.05]
288+
],
289+
[
290+
[0, 0, 4.2],
291+
[1.05, 1.05, 3.1500000000000004]
292+
],
293+
[
294+
[4.2, 0, 0],
295+
[3.1500000000000004, 1.05, 1.05]
296+
]
297+
],
298+
keyframes: [0, 1],
299+
color: '#f9dc3c',
300+
tooltip: 'label',
301+
radius: 0.1,
302+
type: 'cylinders',
303+
clickable: true
304+
},
305+
{
306+
positionPairs: [
307+
[
308+
[2.1, 2.1, 2.1], // starts from center sphere
309+
[1.05, 1.05, 1.05] // end in yellow
310+
],
311+
[
312+
[2.1, 2.1, 2.1],
313+
[3.1500000000000004, 1.05, 1.05]
314+
],
315+
[
316+
[2.1, 2.1, 2.1],
317+
[3.1500000000000004, 3.1500000000000004, 3.1500000000000004]
318+
],
319+
[
320+
[2.1, 2.1, 2.1],
321+
[3.1500000000000004, 1.05, 3.1500000000000004]
322+
],
323+
[
324+
[2.1, 2.1, 2.1],
325+
[1.05, 3.1500000000000004, 1.05]
326+
],
327+
[
328+
[2.1, 2.1, 2.1],
329+
[3.1500000000000004, 3.1500000000000004, 1.05]
330+
],
331+
[
332+
[2.1, 2.1, 2.1],
333+
[1.05, 1.05, 3.1500000000000004]
334+
],
335+
[
336+
[2.1, 2.1, 2.1],
337+
[1.05, 3.1500000000000004, 3.1500000000000004]
338+
]
339+
],
340+
keyframes: [0, 1],
341+
color: '#a121f6',
342+
radius: 0.1,
343+
type: 'cylinders',
344+
tooltip: 'label',
345+
clickable: true
346+
}
347+
],
348+
origin: [-2.1, -2.1, -2.1],
349+
visible: true
350+
},
351+
{
352+
name: 'cubes',
353+
contents: [
354+
{
355+
positions: [
356+
[4, 4, 4],
357+
[10, 10, 10]
358+
],
359+
width: 2,
360+
color: '#ababaa',
361+
type: 'cubes',
362+
tooltip: 'label',
363+
keyframes: [0, 1]
364+
}
365+
]
366+
},
367+
{
368+
name: 'polyhedra',
369+
contents: [
370+
{
371+
positions: [
372+
[2.1, 2.1, 2.1],
373+
[0, 0, 0],
374+
[4.2, 0, 0],
375+
[4.2, 4.2, 4.2],
376+
[4.2, 0, 4.2],
377+
[0, 4.2, 0],
378+
[4.2, 4.2, 0],
379+
[0, 0, 4.2],
380+
[0, 4.2, 4.2]
381+
],
382+
keyframes: [0, 1],
383+
color: '#a121f6',
384+
type: 'convex'
385+
}
386+
],
387+
origin: [-2.1, -2.1, -2.1],
388+
tooltip: 'label',
389+
visible: true
390+
},
391+
{
392+
name: 'unit_cell',
393+
contents: [
394+
{
395+
name: 'a=4.2, b=4.2, c=4.2, alpha=90.0, beta=90.0, gamma=90.0',
396+
contents: [
397+
{
398+
positions: [
399+
[0, 0, 0],
400+
[4.2, 0, 0],
401+
[0, 0, 0],
402+
[0, 4.2, 0],
403+
[0, 0, 0],
404+
[0, 0, 4.2],
405+
[4.2, 0, 0],
406+
[4.2, 4.2, 0],
407+
[4.2, 0, 0],
408+
[4.2, 0, 4.2],
409+
[0, 4.2, 0],
410+
[4.2, 4.2, 0],
411+
[0, 4.2, 0],
412+
[0, 4.2, 4.2],
413+
[0, 0, 4.2],
414+
[4.2, 0, 4.2],
415+
[0, 0, 4.2],
416+
[0, 4.2, 4.2],
417+
[4.2, 4.2, 0],
418+
[4.2, 4.2, 4.2],
419+
[4.2, 0, 4.2],
420+
[4.2, 4.2, 4.2],
421+
[0, 4.2, 4.2],
422+
[4.2, 4.2, 4.2]
423+
],
424+
keyframes: [0, 1],
425+
type: 'lines'
426+
}
427+
],
428+
visible: false
429+
}
430+
],
431+
origin: [-2.1, -2.1, -2.1],
432+
visible: false
433+
},
434+
{
435+
name: 'axes',
436+
contents: [
437+
{
438+
positionPairs: [
439+
[
440+
[-2.1, -2.1, -2.1],
441+
[-1.4, -1.4, -3.1]
442+
]
443+
],
444+
color: 'red',
445+
radius: 0.07, // / 0.37302772291498865) * 2,
446+
headLength: 0.24,
447+
headWidth: 0.14,
448+
type: 'arrows',
449+
clickable: false
450+
},
451+
{
452+
positionPairs: [
453+
[
454+
[-2.1, -2.1, -2.1],
455+
[-0.1, -2.5, -1.1]
456+
]
457+
],
458+
color: 'green',
459+
radius: 0.07, // / 0.37302772291498865) * 2,
460+
headLength: 0.24, // / 0.37302772291498865,
461+
headWidth: 0.14, // 0.37302772291498865,
462+
type: 'arrows',
463+
clickable: false
464+
},
465+
{
466+
positionPairs: [
467+
[
468+
[-2.1, -2.1, -2.1],
469+
[-1.1, -1.1, -1.1]
470+
]
471+
],
472+
color: 'blue',
473+
radius: 0.07, // 0.37302772291498865) * 2,
474+
headLength: 0.24, // / 0.37302772291498865) * 2,
475+
headWidth: 0.14, // / 0.37302772291498865) * 2,
476+
type: 'arrows',
477+
clickable: false
478+
},
479+
{
480+
positions: [[-2.1, -2.1, -2.1]],
481+
color: 'black',
482+
radius: 0.0175,
483+
type: 'spheres',
484+
clickable: false
485+
}
486+
],
487+
visible: false
488+
}
489+
],
490+
origin: [-2.1, -2.1, -2.1],
491+
visible: true
492+
};
493+
494+
export const s2_old = {
223495
name: '_ct_StructureMoleculeComponent_1',
224496
contents: [
225497
{

src/components/data-display/SearchUI/SearchUIContextProvider/MatscholarSearchUIContextProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ export const MatscholarSearchUIContextProvider: React.FC<SearchState> = ({
234234
const params: any = preprocessQueryParams(
235235
{ ...query, ...props.apiEndpointParams },
236236
state.filterGroups,
237-
defaultQuery
237+
defaultQuery,
238+
''
238239
);
239240
params[props.fieldsKey] = fields;
240241

src/pages/CrystalStructureAnimationViewer/CrystalStructureAnimationViewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ export const CrystalStructureAnimationViewer: React.FC = () => {
184184
extractAxis: false,
185185
zoomToFit2D: true
186186
}}
187-
//data={phonon_scene}
188-
data={phonon_position_scene}
187+
data={phonon_scene}
188+
// data={phonon_position_scene}
189189
sceneSize="100%"
190190
debug={false}
191191
toggleVisibility={{}}

0 commit comments

Comments
 (0)