1.2.2 • Published 5 years ago

use-three v1.2.2

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

use-three

React Hook for Three.js

Installation

npm install use-three --save

Demo

Edit use-three

Usage

import useThree from "use-three";

const Three = useThree({
  onStart: ctx => {},
  onUpdate: ctx => {},
  onDestroy: ctx => {},
  onLoad: ctx => {},
  onLoadProgress: (ctx, item, loaded, total) => {},
  onMouseDown: (e, ctx) => {},
  onMouseMove: (e, ctx) => {},
  onMouseUp: (e, ctx) => {},
  onTouchStart: (e, ctx) => {},
  onTouchEnd: (e, ctx) => {},
  onTouchCancel: (e, ctx) => {},
  onTouchMove: (e, ctx) => {}
});

return <Three />;

API

Parameters

FieldTypeDescription
onStartfunctionThis function will be called before Update method time.
onUpdatefunctionThis function will be called every frame.
onDestroyfunctionThis function will be called when component unmount.
onLoadfunctionThis function will be called when all loading is completed.
onLoadProgressfunctionThis function will be called when an item is complete.
onLoadErrorfunctionThis function will be called when any item errors.
onMouseDownfunctionThis function will be called when the user presses a mouse button.
onMouseMovefunctionThis function will be called when the pointer is moving
onMouseUpfunctionThis function will be called when a user releases a mouse button
onTouchStartfunctionThis function will be called when a finger is placed on a touch screen
onTouchEndfunctionThis function will be called when a finger is removed from a touch screen
onTouchCancelfunctionThis function will be called when the touch is interrupted
onTouchMovefunctionThis function will be called when a finger is dragged across the screen

config

KeyTypeDescription
storeobjectThis is store for saving any variables.
sceneTHREE.SceneScenes allow you to set up what and where is to be rendered by three.js. This is where you place objects, lights and cameras.
rendererTHREE.WebGLRendererThe WebGL renderer displays your beautifully crafted scenes using WebGL.
cameraTHREE.OrthographicCamera or THREE.PerspectiveCameraThis is Three.js camera instance.
managerTHREE.LoadingManagerHandles and keeps track of loaded and pending data.

License

The files included in this repository are licensed under the MIT license.

1.2.2

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago