()
| 541 | this.figure.update(); |
| 542 | } |
| 543 | create_mesh() { |
| 544 | let geo = this.model.get("geo"); |
| 545 | // console.log(geo) |
| 546 | if (!geo) { |
| 547 | geo = "diamond"; |
| 548 | } |
| 549 | const sprite = geo.endsWith("2d"); |
| 550 | const buffer_geo = this.geos[geo];//geo); |
| 551 | const instanced_geo = new THREE.InstancedBufferGeometry(); |
| 552 | |
| 553 | const vertices = (buffer_geo.attributes.position as any).clone(); |
| 554 | instanced_geo.addAttribute("position", vertices); |
| 555 | if(buffer_geo.index) { |
| 556 | instanced_geo.index = buffer_geo.index; |
| 557 | } |
| 558 | instanced_geo.computeVertexNormals(); |
| 559 | |
| 560 | const sequence_index = this.model.get("sequence_index"); |
| 561 | let sequence_index_previous = this.previous_values.sequence_index; |
| 562 | if (typeof sequence_index_previous === "undefined") { |
| 563 | sequence_index_previous = sequence_index; |
| 564 | } |
| 565 | const scalar_names = ["x", "y", "z", "aux", "vx", "vy", "vz", "size", "size_selected"]; |
| 566 | const vector4_names = []; |
| 567 | if (this.model.get("color_scale")) { |
| 568 | scalar_names.push("color", "color_selected"); |
| 569 | } else { |
| 570 | vector4_names.push("color", "color_selected"); |
| 571 | } |
| 572 | const next = new values.Values(scalar_names, [], this.get_next.bind(this), sequence_index, vector4_names); |
| 573 | const previous = new values.Values(scalar_names, [], this.get_previous.bind(this), sequence_index_previous, vector4_names); |
| 574 | |
| 575 | const length = Math.max(next.length, previous.length); |
| 576 | if (length === 0) { |
| 577 | console.error("no single member is an array, not supported (yet?)"); |
| 578 | } |
| 579 | |
| 580 | next.trim(next.length); // make sure all arrays are of equal length |
| 581 | previous.trim(previous.length); |
| 582 | const previous_length = previous.length; |
| 583 | const next_length = next.length; |
| 584 | if (this.model.get("selected") || this.previous_values.selected) { |
| 585 | // upgrade size and size_previous to an array if they were not already |
| 586 | next.ensure_array(["size", "size_selected", "color", "color_selected"]); |
| 587 | previous.ensure_array(["size", "size_selected", "color", "color_selected"]); |
| 588 | let selected = this.get_next("selected", sequence_index, []); |
| 589 | next.select(selected); |
| 590 | selected = this.get_previous("selected", sequence_index_previous, []); |
| 591 | previous.select(selected); |
| 592 | } |
| 593 | // if we have a change in length, we use size to fade in/out particles, so make sure they are arrays |
| 594 | if (next.length !== previous.length) { |
| 595 | next.ensure_array("size"); |
| 596 | previous.ensure_array("size"); |
| 597 | } |
| 598 | if (next.length > previous.length) { // grow.. |
| 599 | previous.pad(next); |
| 600 | (previous.array.size as any).fill(0, previous_length); // this will make them smoothly fade in |
no test coverage detected