1.1.2 • Published 4 years ago

use-three-transient-updates v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

use-three-transient-updates

what are transient updates?

Further explain about transient updates.

Discussion about implementation.

Usage

Full example: react-encompass-ecs-example

import { useComponent } from 'react-encompass-ecs';
import { useTransientDataList } from 'use-three-transient-updates';

function Planes() {
  const { boxes } = useComponent({ boxes: [PositionComponent] });
  const refs = useTransientDataList(boxes, ([{ x, y }]) => ({ position: [x, y, 0] }));
  return (
    <>
      {refs.map((_, index) => (
        <mesh ref={refs[index]} receiveShadow={true} key={index}>
          <planeBufferGeometry attach="geometry" args={[20, 20]} />
          <meshPhongMaterial attach="material" color="#272727" />
        </mesh>
      ))}
    </>
  );
}
import { useComponent } from 'react-encompass-ecs';
import { useTransientData } from 'use-three-transient-updates';

function Plane({ position, index }: { position: { x: number, y: number }, index: number }) {
  return (
    <mesh
      ref={useTransientData({ position }, ({ position: { x, y } }) => ({ position: [x, y, 0] }))}
      receiveShadow={true}
    >
      <planeBufferGeometry attach="geometry" args={[20, 20]} />
      <meshPhongMaterial attach="material" color="#272727" />
    </mesh>
  );
}
1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago