Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Instanced Mesh #74

Answered by IRobot1
IRobot1 asked this question in Q&A
Discussion options

You must be logged in to vote

The following example shows how to set color and scale using instaned mesh

    <ngt-instanced-mesh #inst="ngtInstancedMesh" [args]="[data.length]" (ready)="ready(inst.mesh)">
      <ngt-box-geometry></ngt-box-geometry>
      <ngt-mesh-standard-material></ngt-mesh-standard-material>
    </ngt-instanced-mesh>
  gap = 1.05
  data = new Array(1000).fill(0).map((d, index) => ({
    position: new Vector3(0, Math.floor(index / 30) * this.gap, (index % 30) * this.gap - 15),
    scale: new Vector3(Math.random(), Math.random(), Math.random()),
    color: new Color().setHex(Math.random() * 0xffffff) //.setColorName('white')
  }));

  ready(inst: InstancedMesh) {

    this.data.forEach((item, index) => 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by IRobot1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant